Webpack Angular 5网页包3 aot构建
我们最近从angular 4升级到angular 5。我们还升级到了网页3。通过去掉main.aot.ts并直接指向main.ts,我们成功地使aot构建正常工作,但是我们无法加载构建。我们看到“AppService未定义”错误。有人能帮忙吗 梅因酒店Webpack Angular 5网页包3 aot构建,webpack,aot,angular5,angular-aot,Webpack,Aot,Angular5,Angular Aot,我们最近从angular 4升级到angular 5。我们还升级到了网页3。通过去掉main.aot.ts并直接指向main.ts,我们成功地使aot构建正常工作,但是我们无法加载构建。我们看到“AppService未定义”错误。有人能帮忙吗 梅因酒店 import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; import {AppModule} from './app.module'; platformB
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './app.module';
platformBrowserDynamic().bootstrapModule(AppModule);
webpack.config.js
module.exports = {
bail: true,
resolve: {
extensions: ['.js', '.ts'],
alias: {
jquery: "jquery/src/jquery"
}
},
entry: {
'app': './app/main.ts',
},
output: {
path: './compiled',
filename: '[name].js',
chunkFilename: '[id].chunk.js'
},
plugins: [
new ngToolsWebpack.AngularCompilerPlugin({
tsConfigPath: './tsaotconfig.json',
entryModule: __dirname + '/../app/app.module#AppModule'
}),
]
}
错误
我能够在
AOT
我创建了一个示例angular5应用程序,它生成AOT
和JIT
,可能与您的结构不同,但可以正常工作
这个提交差异将更好地描述我在升级到angular5时所做的更改
用于angular5的tsconfig-aot.json
“angularCompilerOptions”:{“genDir”:“aot”}
|entry:'./js/ng2/app/main.jit.ts'
const{AngularCompilerPlugin}=require('@ngtools/webpack')代码>和插件中的新AngularCompilerPlugin({tsconfig路径:'./tsconfig aot.json',entryModule:…})
在答案中添加了更多详细信息,请根据我的最新答案重新评估否决票,否则仍需删除?这样更好。对于其他用户的反对票,我无能为力——我的方法通常是通过评论提出改进建议。写好答案的习惯往往会随着时间的推移而得到回报。
Uncaught ReferenceError: AppService is not defined
at e.ctorParameters (http://localhost:4200/bundle/app.js:1:915567)
at e._ownParameters (http://localhost:4200/bundle/app.js:1:60309)
at e.parameters (http://localhost:4200/bundle/app.js:1:60727)
at e.parameters (http://localhost:4200/bundle/app.js:1:1250184)
at e._getDependenciesMetadata (http://localhost:4200/bundle/app.js:1:1439376)
at e._getTypeMetadata (http://localhost:4200/bundle/app.js:1:1438259)
at e.getNonNormalizedDirectiveMetadata (http://localhost:4200/bundle/app.js:1:1431328)
at e._getEntryComponentMetadata (http://localhost:4200/bundle/app.js:1:1442081)
at http://localhost:4200/bundle/app.js:1:1441836
at Array.forEach (native)
{
"compilerOptions": {
"module": "es2015",
"moduleResolution": "node",
"target": "es5",
"noImplicitAny": false,
"sourceMap": true,
"mapRoot": "",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2015",
"dom"
],
"outDir": "aot",
"skipLibCheck": true,
"rootDir": "."
}
}