Webpack - AngularJS 应用程序无法在 IE11 上运行

Webpack - AngularJS app not working on IE11

AngularJS 应用程序正在使用 webpack,创建了一些模块,这些模块也可以与 webpack 一起使用。当 运行 该应用程序在所有浏览器中运行时,除 IE11 外,一切正常。这是 IE11 控制台中显示的当前错误。

SCRIPT1006: Expected ')'
File: vendor.bundle.js, Line 1, Column 546833

错误出现在已 "webpackified" 的导入模块之一上,尝试删除该模块,但我们的另一个位于不同存储库中的组件出错了。我想这可能是一个 webpack 错误,babel 会解决这个问题。

.bablerc

{
"presets": [
    [ "env", {
     "targets": {
      "browsers": ["last 2 versions", "ie >= 11"]
    },
          "useBuiltIns": true
      }]
    ]
}

package.json

"devDependencies":{
  "babel-core": "^6.26.3",
  "babel-loader": "^7.1.4",
  "babel-polyfill": "^6.26.0",
  "babel-preset-env": "^1.7.0",
  "eslint": "^5.0.1",
  "eslint-loader": "^2.0.0",
  "file-loader": "^1.1.11",
  "happypack": "^5.0.0",
  "hard-source-webpack-plugin": "^0.9.0",
  "html-loader": "^0.5.5",
  "html-webpack-plugin": "^3.2.0",
  "json-loader": "^0.5.7"
},
"dependencies":{
  ...,
  "dataservice": "git+ssh://git@<remote-server>/dataService.get#webpackify",
  "cart": "git+ssh://git@<remote-server>/cart.git#webpackify"
},
"externals": [
  "dataservice/app",
  "cart/app"
]

使用 angularJS 版本“^1.7.2”和 webpack 版本“^4.12.1”

inside webpack.config.js 具有构建外部模块以及 angularJS 应用程序中当前 javascript 文件的功能。

webpack.config.js

module.exports = {
  entry: ["babel-polyfill", "./scripts/app.js"],
  modules.rules: [
    {  
      enforce: 'pre',
      test: /\.js$/,
      include: build_externals(),
      loader: 'eslint-loader'
    },
    {
      test: /\.js$/,
      include: build_externals(),
      use: 'happypack/loader?id=ECMAScript'
    }
  ],
  plugins: [
    {
     loader: 'babel-loader',
     options: {
      presets: ['env'],
      plugins: ['transform-es2015-modules-commonjs']
     }
   },
   new HappyPack({
    id: 'ECMAScript',
    threads: 4,
    loaders: happy_js_loader
   })
  ]
}

这个问题让我失去了理智。希望有人能提供帮助。提前致谢。

原来我的问题的解决方案是为外部模块提供正确的路径。 Webpack 在构建过程中包含这些。 IE浏览器完美运行。

package.json

"externals": [
 "node_modules/dataservice/app",
 "node_modules/cart/app"
]