I want to remove the global 'use strict' that babel-preset-env adds with babel 6.x.
I read the other post about es2015.
I've tried the following .babelrc configuration, to no avail:
{
"presets": [["env", {"loose":true}]],
"plugins": [
["transform-es2015-modules-commonjs", {
"strict" : false
}]
]
}
I do not want to edit the actual file in node_modules as the other post suggested for es2015. That's quite a hack and won't persist.
The only solution so far is to use gulp-iife to wrap every file. Is there really no way to pass an option in my .babelrc file to disable this?
Which plugin in 'env' is even doing this?
Thanks
No, you can't disable strict mode per function. Notice how we can define function outside of strict code and then pass it into the function that's strict. You can do something similar in your example — have an object with "sloppy" functions, then pass that object to that strict immediately invoked function.
@babel/preset-env is a smart preset that allows you to use the latest JavaScript without needing to micromanage which syntax transforms (and optionally, browser polyfills) are needed by your target environment(s). This both makes your life easier and JavaScript bundles smaller!
Using a Preset Within a Babel config, if the preset is on npm, you can pass in the name of the preset and Babel will check that it's installed in node_modules already. This is added to the presets config option, which takes an array. Otherwise, you can also specify a relative or absolute path to your presets.
Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments.
Set the modules
option of the env
preset to false
:
{
"presets": [
["env", { "modules": false }]
]
}
From babel documentation:
modules
"amd" | "umd" | "systemjs" | "commonjs" | false
, defaults to"commonjs"
.Enable transformation of ES6 module syntax to another module type.
Setting this to false will not transform modules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With