TypeScript不喜欢类型定义返回

时间:2019-01-18 08:55:24

标签: typescript webpack babel

尝试在从私有git repo导入模块的项目上运行webpack时出现错误

以下错误发生在一个文件中,该文件未从我要导入的文件中引用(只有一个atm),并且不应真正在上进行解析,但是它是在简单的ts上语法的东西。

错误:

SyntaxError: C:\projects\app-fixed-asset-disposal\node_modules\workflow-engine\src\helpers\includes-all.ts: Unexpected token, exp
ected "{" (3:53)

  1 | import * as _ from 'lodash';
  2 | 
> 3 | export default function includesAll(needle, haystack): Boolean {

.babelrc

{
  "presets": [
    "@babel/typescript",
    [
      "@babel/env",
      {
        "modules": false
      }
    ]
  ],
  "plugins": [
    "@babel/plugin-proposal-class-properties",
    "@babel/plugin-proposal-export-default-from",
    "@babel/proposal-object-rest-spread"
  ],
  "ignore": [
    "node_modules"
  ]
}

webpack.config.js

const path = require('path'),
    CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');

module.exports = {
    entry: './server.ts',
    mode: 'development',
    target: 'node',
    devtool: 'source-map',
    output: {
        filename: 'server.js',
        path: path.resolve(__dirname, 'dist')
    },
    plugins: [
        new CaseSensitivePathsPlugin()
    ],
    module: {
        rules: [
            {
                test: /\.ts?$/,
                use: 'babel-loader'
            },
        ]
    },
    resolve: {
        extensions: ['.tsx', '.ts', '.js']
    },
    optimization: {
        usedExports: true
    }
};

0 个答案:

没有答案