使用webpack构建angular2应用-找不到./compiler.es5.ts [英] Build angular2 app with webpack - can't find ./compiler.es5.ts
问题描述
我正在使用webpack来构建angular2应用.将angular2从2.3.1升级到4.0.1后,webpack将输出以下Warning
:
I'm using webpack to build an angular2 app. after upgrading angular2 from 2.3.1 to 4.0.1, webpack is outputting the following Warning
:
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
.
The message is correct because there is not such a file with ts
extension at that location, the file exist but has js
extension.
我会误认为webpack的配置值吗?
Do I mis a webpack configuration value?
顺便说一句:如果我使用@ angular/cli v1.0来构建应用程序,则不会看到警告.
BTW: I do not see the warning, if I use @angular/cli v1.0 to build the app.
推荐答案
在 https://github.com/angular-redux/store/issues/64
解决方法是在webpack.config.js中为source-map-loader添加exclude
规则.
Workaround is adding exclude
rule for source-map-loader in your webpack.config.js.
{
test: /\.(js|ts)$/,
exclude: [
// workaround for this issue
path.join(__dirname, 'node_modules', '@angular/compiler')
],
use: [{
loader: 'source-map-loader'
}],
enforce: 'pre'
}
但是上面的解决方法不过是临时的.
But this workaround above is no more than temporary one.
这篇关于使用webpack构建angular2应用-找不到./compiler.es5.ts的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!