2016-09-14 60 views
3

bundeling更新到Angular2 RC7在瀏覽器中運行時,我得到了folloing JavaScript錯誤後:不定義「OuterSubscriber沒有定義」 與rollup.js

OuterSubscriber

這隻當我使用rollup.js創建一個包時發生。如果我運行未捆綁JavaScript的應用程序,它可以正常工作。

錯誤必須以某種方式與rxjs相關,因爲OuterSubscriber是其中的一部分。我檢查了捆綁軟件,但在那裏找不到OuterSubscriber。我想rollup.js認爲這是沒有必要的,因此不包括它。

環境:

  • angular, v2.0.0-rc.7
  • rxjs, v5.0.0-beta.12
  • systemjs, v0.19.27
  • gulp-rollup, v2.4.0
  • rollup-stream, v1.13.0

system.js配置I映射umd模塊(例如, core.umd.js)爲angular。對於rxjs,我使用了一個經典的映射,如example

有沒有人有一個想法,我在做什麼錯在這裏?

+0

問題我運行angular2 RC6和rxjs 5測試版11,有同樣的問題。 – rgripper

回答

0

彙總0.34.0作品與2.0.0-rc.7和核實彙總0.34.0作品與2.0.0還但我能夠複製與0.35.0

+0

修復了此問題。我只需確保其他npm軟件包不需要rolloup大於0.34.x,然後運行。非常感謝。 – tschuege

0

目前rollup似乎有兩個問題。

  • rollup不路徑('/' VS '\\')和issue is still open正常化斜線。要修復它rollup.config.js需要補充如下:
resolveId(id, from){ 
    if (id.startsWith('rxjs/') || id.startsWith('rxjs\\')){ 
     let result = `${__dirname}/node_modules/rxjs-es/${id.replace('rxjs/', '')}.js`; 
     return result.replace(/\//g, "\\"); // Add this 
    } 
} 
  • 它打破ES2015代碼,但ES5正常工作,所以它需要編譯rxjs-es與ES2015模塊ES5,使彙總解析器用它來代替。這裏是一個獨立的tsconfig.rx.json
{ 
    "compilerOptions": { 
     "target": "ES5", 
     "module": "ES2015", 
     "moduleResolution": "node", 
     "sourceMap": true, 
     "emitDecoratorMetadata": true, 
     "experimentalDecorators": true, 
     "removeComments": true, 
     "noImplicitAny": false, 
     "skipLibCheck": true, 
     "outDir": "temp/rxjs", 
     "allowJs": true 
    }, 
    "include": [ 
     "node_modules/rxjs-es/**/*.js" 
    ], 
    "exclude": [ 
     "wwwroot", 
     "node_modules/rxjs-es/rx.js" 
    ] 
} 

rollup.config.js

resolveId(id, from){ 
    if (id.startsWith('rxjs/') || id.startsWith('rxjs\\')){ 
     let result = `${__dirname}/temp/rxjs/${id.replace('rxjs/', '')}.js`; 
     //let result = `${__dirname}/node_modules/rxjs-es/${id.replace('rxjs/', '')}.js`; 
     return result.replace(/\//g, "\\"); 
    } 
} 
+0

我已驗證我的包中缺少OuterSubscriber – codescholar

+0

我已驗證我的包中缺少OuterSubscriber,但是我正在從OS X運行,上述解決方案適用於Windows機器 – codescholar

+0

第二部分可能實際上修復了您的問題 – rgripper