简体   繁体   English

从babel-preset-env中删除全局“use strict”

[英]Remove Global "use strict' from babel-preset-env

I want to remove the global 'use strict' that babel-preset-env adds with babel 6.x. 我想删除babel-preset-env与babel 6.x一起添加的全局'use strict'。

I read the other post about es2015. 我读了关于es2015的另一篇文章。

I've tried the following .babelrc configuration, to no avail: 我尝试了以下.babelrc配置,无济于事:

{
  "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. 我不想像在es2015中建议的其他帖子一样编辑node_modules中的实际文件。 That's quite a hack and won't persist. 这是一个非常黑客,不会坚持下去。

The only solution so far is to use gulp-iife to wrap every file. 到目前为止,唯一的解决方案是使用gulp-iife来包装每个文件。 Is there really no way to pass an option in my .babelrc file to disable this? 真的没有办法在我的.babelrc文件中传递一个选项来禁用它吗?

Which plugin in 'env' is even doing this? 'env'中的哪个插件甚至可以这样做?

Thanks 谢谢

Set the modules option of the env preset to false : env预设的modules选项设置为false

{ 
  "presets": [
       ["env", { "modules": false }]
  ]
}

From babel documentation : 来自babel文档

modules 模块
"amd" | "umd" | "systemjs" | "commonjs" | false "amd" | "umd" | "systemjs" | "commonjs" | false , defaults to "commonjs" . "amd" | "umd" | "systemjs" | "commonjs" | false ,默认为"commonjs"

Enable transformation of ES6 module syntax to another module type. 启用将ES6模块语法转换为其他模块类型。

Setting this to false will not transform modules. 将此设置为false将不会转换模块。

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

相关问题 带有babel-preset-env的gulp-babel会忽略浏览器列表 - gulp-babel with babel-preset-env ignores browserslist 使用babel-preset-env禁用promise转换? - Disable promise transpilation using babel-preset-env? babel-preset-env没有使用webpack转换箭头函数 - babel-preset-env not transpiling arrow functions using webpack babel-preset-env语法错误:带有传播属性的意外标记 - babel-preset-env SyntaxError: Unexpected token with spread properties 禁用babel-preset-env的园区功能 - Dont work park functionality of babel-preset-env 什么是babel-preset-es2015和babel-preset-env之间的区别? - Whats the difference between babel-preset-es2015 and babel-preset-env? 添加babel-preset-env和babel-preset-stage-2时,生成器运行时错误 - Generator Runtime error when added babel-preset-env and babel-preset-stage-2 错误:找不到模块 'babel-preset-env' - 你是说“@babel/env”吗? - Error: Cannot find module 'babel-preset-env' - Did you mean "@babel/env"? 如何删除 babel 添加的全局“use strict” - How to remove global "use strict" added by babel 将polyfill作为带有babel-preset-env的import语句或将它们添加到webpack.config.js的条目中是否更好? - Is it better to have polyfills as import statements with babel-preset-env or add them in entries at webpack.config.js?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM