angular2 aot - Angular 4 AOT Compiler -
i want set aot compiler application
when run node_modules/.bin/ngc -p tsconfig-aot.json compiles , gives no errors.
but when try run ng serve gives me error:
tried find bootstrap code, not. specify either statically analyzable bootstrap code or pass in entrymodule plugins options.
error: tried find bootstrap code, not. specify either statically analyzable bootstrap code or pass in entrymodule plugins options. @ object.resolveentrymodulefrommain (/path/node_modules/@ngtools/webpack/src/entry_resolver.js:128:11) @ aotplugin._setupoptions (/path/node_modules/@ngtools/webpack/src/plugin.js:143:50) @ new aotplugin (/path/node_modules/@ngtools/webpack/src/plugin.js:26:14) @ _createaotplugin (/path/node_modules/@angular/cli/models/webpack-configs/typescript.js:55:12) @ object.exports.getnonaotconfig (/path/node_modules/@angular/cli/models/webpack-configs/typescript.js:70:19) @ ngcliwebpackconfig.buildconfig (/path/node_modules/@angular/cli/models/webpack-config.js:27:37) @ class.run (/path/node_modules/@angular/cli/tasks/serve.js:38:98) @ check_port_1.checkport.then.port (/path/node_modules/@angular/cli/commands/serve.js:110:26) @ <anonymous> @ process._tickcallback (internal/process/next_tick.js:188:7) main.ts
import { platformbrowser } '@angular/platform-browser'; import { appmodulengfactory } '../aot/src/app/main/app.module.ngfactory'; console.log('running aot compiled'); platformbrowser().bootstrapmodulefactory(appmodulengfactory);
node_modules/.bin/ngc -p tsconfig-aot.json compiles files output folder. can use http server run files folder.
however not how it's done when developing angular-cli. ng serve uses own development server doesn't care output folder. stated in official docs:
ng servebuilds application , starts web server.... below additional options.
-- aot
so need use --aot option:
ng serve --aot and don't need modify main.ts file. should have boostrapmodule , not boostrapmodulefactory method.
Comments
Post a Comment