问题
I am trying to implement ngc compilation config on my angular/webpack app. I have a tsConfig-aot.json in my root folder like below.
{
....
"files": [
"src/app/app.module.ts",
"src/app/lazy/about/about.module.ts",
"src/app/lazy/employees/employees.module.ts",
"src/app/lazy/login/login.module.ts",
"src/app/lazy/employee-details/employee-details.module.ts"
],
"include": [
"src/polyfills.ts",
"src/vendor.ts"
],
"exclude": [
"./node_modules",
"./**/*.e2e.ts",
"./**/*.spec.ts",
"./src/main-aot.ts"
],
"angularCompilerOptions": {
"genDir": "./aot",
"skipMetadataEmit": true
}
}
And my webpack is configured as below .
module.exports = {
entry: {
'polyfills': './src/polyfills.ts',
'vendor': './src/vendor.ts',
'app': './src/main-aot.ts'
},
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts$/,
loaders: [
{
loader: '@ngtools/webpack',
options: { configFileName: helpers.root('tsconfig-aot.json') }
}, 'angular-router-loader?aot=true&genDir=aot/', 'angular2-template-loader'
],
exclude: [/node_modules/, /\.(spec|e2e)\.ts$/]
},
]
},
plugins: [
new AngularCompilerPlugin({
tsConfigPath: 'tsconfig-aot.json',
sourceMap: true
}),
new webpack.optimize.CommonsChunkPlugin({
names: ['app', 'vendor', 'polyfills']
}),
...
]
};
I am trying to implement the aot build config for my app. However, when i run ./node_modules/.bin/ngc -p ./tsconfig-aot.json
. My app compilation fails with the error saying
src/main-aot is missing from the TypeScript compilation
My main.aot is written as below
import { platformBrowser } from '@angular/platform-browser';
import { enableProdMode } from '@angular/core';
import { AppModuleNgFactory } from '../aot/src/app/app.module.ngfactory';
enableProdMode();
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
When i update my tsconfig-aot
to by adding main-aot in files object, the error changed to "aot/src/app/app.module.ngfactory" has no exported member 'AppModuleNgFactory'
. I presumed the later is because the aot folder has not been generated yet. Please how do i properly configure this ? Any help would be appreciated.
来源:https://stackoverflow.com/questions/48862003/main-aot-is-missing-from-the-typescript-compilation