我的Angualr项目加载非常慢。所以我编译Angular AOT,但输出错误信息。
tsconfig-aot.json:
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es2015", "dom"],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"typeRoots": [
"./node_modules/@types/"
],
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": false
},
"files": [
"src/app/app.module.ts",
"src/main.ts"
],
"angularCompilerOptions": {
"genDir": "aot",
"skipMetadataEmit" : true
}
}
main.ts:
import { platformBrowser } from '@angular/platform-browser';
import { AppModuleNgFactory } from '../aot/src/app/app.module.ngfactory';
platformBrowser().bootstrapModuleFactory( AppModuleNgFactory );
node_modules / .bin / ngc -p tsconfig-aot.json。
ng serve。
1-> 2。
错误消息:
Tried to find bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options.
Error: Tried to find bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options.
at Object.resolveEntryModuleFromMain (/Users/ATHeart/DEV/Com/Project/web.cosmo/frontend/node_modules/@angular/cli/node_modules/@ngtools/webpack/src/entry_resolver.js:130:11)
at AotPlugin._setupOptions (/Users/ATHeart/DEV/Com/Project/web.cosmo/frontend/node_modules/@angular/cli/node_modules/@ngtools/webpack/src/plugin.js:157:50)
at new AotPlugin (/Users/ATHeart/DEV/Com/Project/web.cosmo/frontend/node_modules/@angular/cli/node_modules/@ngtools/webpack/src/plugin.js:30:14)
at _createAotPlugin (/Users/ATHeart/DEV/Com/Project/web.cosmo/frontend/node_modules/@angular/cli/models/webpack-configs/typescript.js:55:12)
at Object.exports.getNonAotConfig (/Users/ATHeart/DEV/Com/Project/web.cosmo/frontend/node_modules/@angular/cli/models/webpack-configs/typescript.js:72:19)
at NgCliWebpackConfig.buildConfig (/Users/ATHeart/DEV/Com/Project/web.cosmo/frontend/node_modules/@angular/cli/models/webpack-config.js:29:37)
at Class.run (/Users/ATHeart/DEV/Com/Project/web.cosmo/frontend/node_modules/@angular/cli/tasks/serve.js:71:98)
at check_port_1.checkPort.then.port (/Users/ATHeart/DEV/Com/Project/web.cosmo/frontend/node_modules/@angular/cli/commands/serve.js:121:26)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
如何解决此错误(Angualr AOT)