我正在尝试利用 RC.6 中提供的新 AOT 编译,但遇到了障碍。我可以使用 ngc => Rollup => Babel 成功创建一个包,但是每次运行 Rollup 时都会收到多个警告:
The 'this' keyword is equivalent to
不明确的at the top level of an ES module, and has been rewritten
捆绑包成功完成。相同的代码库适用于 JIT 编译。Angular 2 应用程序启动速度很快,但每次我尝试导航到 root 以外的另一条路线时,我都会收到此错误:
```
bundle.js:2781 EXCEPTION: Uncaught (in promise): EmptyError: no elements in sequenceErrorHandler.handleError @ bundle.js:2781
bundle.js:2781 ORIGINAL STACKTRACE:ErrorHandler.handleError @ bundle.js:2781
bundle.js:2781 Error: Uncaught (in promise): EmptyError: no elements in sequence
at resolvePromise (zone.js:558)
at zone.js:535
at ZoneDelegate.invoke (zone.js:332)
at Object.onInvoke (bundle.js:3549)
at ZoneDelegate.invoke (zone.js:331)
at Zone.run (zone.js:225)
at zone.js:591
at ZoneDelegate.invokeTask (zone.js:365)
at Object.onInvokeTask (bundle.js:3549)
at ZoneDelegate.invokeTask (zone.js:364)ErrorHandler.handleError @ bundle.js:2781
zone.js:484 Unhandled Promise rejection: no elements in sequence ; Zone: angular ; Task: Promise.then ; Value: Error: no elements in sequence
at new EmptyError (bundle.js:7019)
at FirstSubscriber._complete (bundle.js:7071)
at FirstSubscriber.complete (bundle.js:3410)
at MergeAllSubscriber._complete (bundle.js:6854)
at MergeAllSubscriber.complete (bundle.js:3410)
at MapSubscriber._complete (bundle.js:3410)
at MapSubscriber.complete (bundle.js:3410)
at EmptyObservable._subscribe (bundle.js:6598)
at EmptyObservable.subscribe (bundle.js:3441)
at Observable.subscribe (bundle.js:3441) EmptyError: no elements in sequence
at new EmptyError (http://localhost:4200/bundle.js:7019:243)
at FirstSubscriber._complete (http://localhost:4200/bundle.js:7071:1680)
at FirstSubscriber.complete (http://localhost:4200/bundle.js:3410:99)
at MergeAllSubscriber._complete (http://localhost:4200/bundle.js:6854:783)
at MergeAllSubscriber.complete (http://localhost:4200/bundle.js:3410:99)
at MapSubscriber._complete (http://localhost:4200/bundle.js:3410:547)
at MapSubscriber.complete (http://localhost:4200/bundle.js:3410:99)
at EmptyObservable._subscribe (http://localhost:4200/bundle.js:6598:234)
at EmptyObservable.subscribe (http://localhost:4200/bundle.js:3441:223)
at Observable.subscribe (http://localhost:4200/bundle.js:3441:187)consoleError @ zone.js:484
zone.js:486 Error: Uncaught (in promise): EmptyError: no elements in sequence
at resolvePromise (zone.js:558)
at zone.js:535
at ZoneDelegate.invoke (zone.js:332)
at Object.onInvoke (bundle.js:3549)
at ZoneDelegate.invoke (zone.js:331)
at Zone.run (zone.js:225)
at zone.js:591
at ZoneDelegate.invokeTask (zone.js:365)
at Object.onInvokeTask (bundle.js:3549)
at ZoneDelegate.invokeTask (zone.js:364)
```
ngc 编译时没有任何警告或错误。
我的 rollup.config.js 如下:
```
// rollup.config.js
import alias from 'rollup-plugin-alias';
import resolve from 'rollup-plugin-node-resolve';
export default {
entry: 'main.js',
format: 'iife',
dest: 'dist/bundle.es2015.js',
sourceMap: false,
plugins: [
alias({ rxjs: __dirname + '/node_modules/rxjs-es' }),
resolve({ module: true })
]
}
```
当使用 Babel 将 ES2015 捆绑包转换为 ES5 时,我收到以下警告:
[BABEL] Note: The code generator has deoptimised the styling of "./dist/bundle.es2015.js" as it exceeds the max of "100KB".
可能是什么问题?
问候,史蒂夫