I want to transpile ES6 to ES5 since we're forced to support IE11 and have some trouble with modern scripts. My bundle contains Sweetalert2 and window
got undefined
after babel.
Input
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.Sweetalert2 = factory());
}(this, (function () { 'use strict';
// ...
After babel processing:
(function (global, factory) {
(typeof exports === "undefined" ? "undefined" : _typeof2(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.Sweetalert2 = factory();
})(void 0, function () {
'use strict';
// ....
I found How to stop babel from transpiling 'this' to 'undefined' and since the preset-es2015 package is considered as deprecated, I thought that using @babel/preset-env
the up2date repalcement for my babel7 is "esmodules": false
but it's not working.
.babelrc
{
"ignore": ["gulpfile.js"],
"presets": [
[
"@babel/preset-env",
{
"targets": {
"esmodules": false
}
}
]
]
}