问题描述
我正在使用使用严格的函数形式,并且不希望Babel在转换后添加的全局形式。问题是我正在使用一些不使用use strict模式的库,并且在脚本连接后可能会抛出错误
I'm using function form of "use strict" and don't want global form which Babel adds after transpilation. The problem is I'm using some libraries that aren't using "use strict" mode and it might throw error after scripts are concatenated
推荐答案
Babel 5
您将黑名单useStrict
。例如,这是Gruntfile中的一个示例:
Babel 5
You'd blacklist "useStrict"
. For instance here's an example in a Gruntfile:
babel: {
options: {
blacklist: ["useStrict"],
// ...
},
// ...
}
Babel 6
因为Babel 6是,而不是将 useStrict列入黑名单
,你只是不包括。如果你正在使用包含它的预设,我认为你必须创建自己的包含所有其他的预设,但不包括那个。
Babel 6
Since Babel 6 is fully opt-in for plugins now, instead of blacklisting useStrict
, you just don't include the strict-mode
plugin. If you're using a preset that includes it, I think you'll have to create your own that includes all the others, but not that one.
这篇关于如何删除全局“use strict”由babel添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!