Remove Global "use strict' from babel-preset-env

5.5k Views Asked by At

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

1

There are 1 best solutions below

0
On

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.