Skip to main content

@babel/plugin-bugfix-firefox-class-in-computed-class-key

此错误修复插件会转换其他类的计算键内的类,以使用私有类元素解决 蜘蛛猴错误 问题。

¥This bugfix plugin transforms classes inside computed keys of other classes to workaround a SpiderMonkey bug with private class elements.

提示

该插件包含在 @babel/preset-env 中,当你的 targets 受到浏览器 bug 影响时,Babel 会自动为你启用该插件。

¥This plugin is included in @babel/preset-env, and Babel will automatically enable this plugin for you when your targets are affected by the browser bug.

警告

早于 5.30.2 的 Terser 版本将撤消此插件完成的转换。确保至少使用版本 5.30.2,或将 Terser 的 compress.inline 选项设置为 false

¥Terser versions older than 5.30.2 will undo the transform done by this plugin. Make sure to use at least version 5.30.2, or set the Terser's compress.inline option to false.

安装

¥Installation

npm install --save-dev @babel/plugin-bugfix-firefox-class-in-computed-class-key

用法

¥Usage

¥With a configuration file (Recommended)

babel.config.json
{
"plugins": ["@babel/plugin-bugfix-firefox-class-in-computed-class-key"]
}

通过 CLI

¥Via CLI

Shell
babel --plugins @babel/plugin-bugfix-firefox-class-in-computed-class-key script.js

通过 Node API

¥Via Node API

JavaScript
require("@babel/core").transformSync("code", {
plugins: ["@babel/plugin-bugfix-firefox-class-in-computed-class-key"],
});