2015-12-23 66 views
0

我使用的WebPack與巴貝爾裝載機,什麼都預設es2015,我看到這樣的煩惱:包括木偶(v.2.4.3)es2015預設變化this agrument在/lib/core/backbone.marionette.js:26undefined,而不是當this。但是這個參數取root變量(line 10),他看到什麼參數是undefined(不是this)和輸出錯誤。木偶與ES2015巴貝爾預設不工作

我看,es2015預設什麼包括babel-plugin-transform-es2015-modules-commonjs,還有什麼包括babel-plugin-transform-strict-mode,哪些是針對嚴格模式和關閉es6模塊的響應。

我試圖修改es2015插件,將require("babel-plugin-transform-es2015-modules-commonjs")更改爲[require("babel-plugin-transform-es2015-modules-commonjs"), {"strict": false}],但這一步並不幫我解決問題。

誰知道,這個問題用木偶,或者es2015預設在babel-loader,還是和我一起,怎麼修復呢?

+0

你只應在運行自己的代碼'通天-loader'。除非你知道你在做什麼,否則你應該從中排除所有庫代碼。 – loganfsmyth

回答

1

我解決了我的問題。我的解決方案是允許頂層這在模塊commonjs。

babel-preset-es2015變化require("babel-plugin-transform-es2015-modules-commonjs")[require("babel-plugin-transform-es2015-modules-commonjs"), { allowTopLevelThis: true }]