webpack 移除严格模式时,需要使用 babel
插件
remove "use strict" directive
方案:
一: 下载安装包
$ npm install babel-plugin-transform-remove-strict-mode
二. 使用方式
1. 如果使用的是 .babelrc (Recommended)
.babelrc 文件添加配置
{
"plugins": ["transform-remove-strict-mode"]
}
2.如果使用的是 CLI
$ babel --plugins transform-remove-strict-mode script.js
3.如果使用的是 Node API
require("babel-core").transform("code", {
plugins: ["transform-remove-strict-mode"]
});