该插件可以通过 babel-plugin-transform-es2015-modules-commonjs
来启用。 如果你想禁用它,你可以关闭 strict
或者在 commonjs 转换中添加 strictMode: false
选项。
输入
foo();
输出
"use strict";
foo();
npm install --save-dev babel-plugin-transform-strict-mode
.babelrc
(推荐).babelrc
未包含选项:
{
"plugins": ["transform-strict-mode"]
}
包含选项:
{
"plugins": [
["transform-strict-mode", {
"strict": true
}]
]
}
babel --plugins transform-strict-mode script.js
require("babel-core").transform("code", {
plugins: ["transform-strict-mode"]
});