Search code examples
javascriptmarionettebabeljsecmascript-6

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. But this argument take root variable (line 10) and he see, what argument is undefined (not this) and output error.

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.

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.

Who know, this problem with Marionette, or es2015 preset in babel-loader, or with me, and how fix it?


Solution

  • I resolve my problem. My solution is allow top level this in modules-commonjs.

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