我正在使用webpack构建一个angular2应用程序.将angular2从2.3.1升级到4.0.1后,webpack输出以下警告:
- WARNING in ./~/@angular/compiler/@angular/compiler.es5.js
- Cannot find source file 'compiler.es5.ts': Error: Can't resolve
- './compiler.es5.ts' in '../node_modules\@angular\compiler\@angular'
- @ ./~/@angular/platform-browser-dynamic/@angular/platform-browser-dynamic.es5.js 11:0-72
消息是正确的,因为在该位置没有这样的带有ts扩展名的文件,该文件存在但具有js扩展名.
我是否错过了webpack配置值?
顺便说一句:如果我使用@ angular / cli v1.0构建应用程序,我看不到警告.
报道了类似的问题
https://github.com/angular-redux/store/issues/64
https://github.com/angular-redux/store/issues/64
解决方法是在webpack.config.js中为source-map-loader添加排除规则.
- {
- test: /\.(js|ts)$/,exclude: [
- // workaround for this issue
- path.join(__dirname,'node_modules','@angular/compiler')
- ],use: [{
- loader: 'source-map-loader'
- }],enforce: 'pre'
- }
但上面的解决方案只不过是暂时的.