2016-09-09 38 views
1

我試圖利用RC.6中提供的新AOT編譯功能,但遇到阻塞程序。我可以成功地創建一個包與NGC =>彙總=>巴貝爾,但是我每次運行彙總時,我得到多個警告:爲什麼ngc + Rollup捆綁Angular 2 RC.6路由失敗?

The 'this' keyword is equivalent to不確定at the top level of an ES module, and has been rewritten

束成功完成。與JIT編譯相同的代碼庫工作正常。該角2個應用白手起家,速度快,但每一次我嘗試導航到根以外的另一條途徑我得到這個錯誤:

```

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 }) 
    ] 
} 

```

與巴貝爾transpiling的ES2015軟件包時,下降到ES5我得到以下警告:

[BABEL] Note: The code generator has deoptimised the styling of "./dist/bundle.es2015.js" as it exceeds the max of "100KB".

什麼可以p可能是問題嗎?

問候, 史蒂夫

+0

我有同樣的問題,以及即使沒有AOT。 tsc(es6/es2015) - >彙總 - > es5。 路由器不適用於特定的路由(應用加載正常,其他一些路由也可以正常工作),但目前爲止找不到原因。 – agsqwe

回答

0

我不能讓巴貝爾6.5.2正確transpile捆綁。根據Rob Wormald的建議,我嘗試使用Closure Compiler從Rollup中傳輸ES2015包輸出,並且它工作正常。只有Java版本看起來很穩定,但是當JS版本能夠順利運行時,我打算將它與我的rollup.config.js進行整合。現在,我通過npm腳本中的一系列異步回調來處理構建。

https://github.com/steveblue/angular2-rollup

https://developers.google.com/closure/compiler