Skip to main content

@babel/plugin-transform-strict-mode

这个插件可以通过 @babel/plugin-transform-modules-commonjs 启用。如果你想禁用它,你可以关闭 strict,或者在 commonjs 转换中传入 strictMode: false 作为选项。

🌐 This plugin may be enabled via @babel/plugin-transform-modules-commonjs. If you wish to disable it you can either turn strict off or pass strictMode: false as an option to the commonjs transform.

示例​

🌐 Example

在

JavaScript
foo();

出

JavaScript
"use strict";

foo();

安装​

🌐 Installation

npm install --save-dev @babel/plugin-transform-strict-mode

用法​

🌐 Usage

🌐 With a configuration file (Recommended)

babel.config.json
{
"plugins": ["@babel/plugin-transform-strict-mode"]
}

通过 CLI​

🌐 Via CLI

Shell
babel --plugins @babel/plugin-transform-strict-mode script.js

通过 Node API​

🌐 Via Node API

JavaScript
require("@babel/core").transformSync("code", {
plugins: ["@babel/plugin-transform-strict-mode"],
});