Webpack - AngularJS应用程序在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
}]
]
}

包.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">

在 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完美运行。

包.json

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

最新更新