我试图利用RC.6中可用的新AOT编译,但遇到阻塞。我可以使用ngc =>成功创建一个包Rollup => Babel,但每次我运行Rollup时都会收到多个警告:
The 'this' keyword is equivalent to
{未定义{1}}
捆绑包成功完成。相同的代码库可以与JIT编译一起使用。 Angular 2应用程序引导速度很快,但每次我尝试导航到root以外的其他路由时都会出现此错误:
```
at the top level of an ES module, and has been rewritten
```
ngc编译时没有任何警告或错误。
我的rollup.config.js如下:
```
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)
```
当使用Babel将ES2015捆绑包转发到ES5时,我收到以下警告:
// 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 })
]
}
可能是什么问题?
此致 史蒂夫
答案 0 :(得分:0)
我无法让Babel 6.5.2正确地传输捆绑包。根据Rob Wormald的建议,我尝试使用Closure Compiler从Rollup转换ES2015捆绑输出,并且它有效。看起来只有Java版本稳定,但是当JS版本顺利运行时,我计划将它与我的rollup.config.js
集成。现在,我通过npm脚本中的一系列异步回调来处理构建。