简体   繁体   English

具有ES2015 babel预设的木偶不起作用

[英]Marionette with ES2015 babel preset dont work

I am using Webpack with babel-loader, what have preset es2015 , and i see this trouble: when including Marionette (v.2.4.3) es2015 preset change this agrument in /lib/core/backbone.marionette.js:26 to undefined instead this . 我正在将Webpack与babel-loader es2015 ,并且已预先设置了es2015 ,但遇到了这个问题:当包含Marionette(v.2.4.3) es2015预设时, 请将 /lib/core/backbone.marionette.js:26中的this agrument 更改undefined代替this But this argument take root variable ( line 10 ) and he see, what argument is undefined (not this ) and output error. 但是此参数采用root变量( 第10行 ),他看到undefined参数(不是this )并输出错误。

I see, what in es2015 preset including babel-plugin-transform-es2015-modules-commonjs , what include babel-plugin-transform-strict-mode , which response for strict mode and close es6 modules. 我看到,在es2015预设中包括babel-plugin-transform-es2015-modules-commonjs ,在包含babel-plugin-transform-strict-mode ,它响应严格模式并关闭es6模块。

I tried to modify es2015 plugin, changing require("babel-plugin-transform-es2015-modules-commonjs") to [require("babel-plugin-transform-es2015-modules-commonjs"), {"strict": false}] , but this step don't help me to solve problem. 我试图修改es2015插件,将require("babel-plugin-transform-es2015-modules-commonjs")更改为[require("babel-plugin-transform-es2015-modules-commonjs"), {"strict": false}] ,但此步骤无法帮助我解决问题。

Who know, this problem with Marionette, or es2015 preset in babel-loader , or with me, and how fix it? 谁知道,“木偶es2015babel-loader预设的es2015或我es2015问题,以及如何解决?

I resolve my problem. 我解决了我的问题。 My solution is allow top level this in modules-commonjs. 我的解决方案是在modules-commonjs中允许顶层使用。

In babel-preset-es2015 change require("babel-plugin-transform-es2015-modules-commonjs") to [require("babel-plugin-transform-es2015-modules-commonjs"), { allowTopLevelThis: true }] babel-preset-es2015require("babel-plugin-transform-es2015-modules-commonjs")更改为[require("babel-plugin-transform-es2015-modules-commonjs"), { allowTopLevelThis: true }]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM