1、首先得AOT
按照官网的例子
https://www.angular.cn/docs/ts/latest/cookbook/aot-compiler.html
注意
"module": "es2015",这里一定要es2015不要commonjs
然后配置main.ts,编译成aot方式
js里面是
import { platformBrowser } from '@angular/platform-browser';这种方式,不是require
2、出现了错误"node_modules/.bin/rollup" -c rollup-config.js ? Error: 'platformBrowser' is not exported by node_modules\@angular\platform-browser\bundles\platform-browser.umd.js https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module src\main.js (1:9) 1: import { platformBrowser } from '@angular/platform-browser'; ^ 2: import { AppModuleNgFactory } from './aot/app/app.module.ngfactory'; 3: console.log('Running AOT compiled');后来发现是自己尝试修改了参数
nodeResolve({jsnext: true,module: true}),--这句正确
被我改成了module: false}),