我们最近从 angular 4 升级到了 angular 5。我们还升级到了 webpack 3。通过摆脱 main.aot.ts 并直接指向 main.ts 来管理我们的 aot 构建工作,但我们无法加载构建. 我们看到“未定义 AppService”错误。有人可以帮忙吗?
main.ts
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'
}),
]
}
错误
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)