@babel/plugin-bugfix-firefox-class-in-computed-class-key
这个补丁插件会把其他类的计算键里面的类进行转换,以绕过 SpiderMonkey 的私有类元素的一个 bug。
🌐 This bugfix plugin transforms classes inside computed keys of other classes to workaround a SpiderMonkey bug with private class elements.
tip
这个插件包含在 @babel/preset-env 中,当你的 targets 受到浏览器错误影响时,Babel 会自动为你启用这个插件。
warning
版本低于 5.30.2 的 Terser 会撤销这个插件做的转换。确保至少使用 5.30.2 版本,或者将 Terser 的 compress.inline 选项设置为 false。
安装
🌐 Installation
- npm
- Yarn
- pnpm
- Bun
npm install --save-dev @babel/plugin-bugfix-firefox-class-in-computed-class-key
yarn add --dev @babel/plugin-bugfix-firefox-class-in-computed-class-key
pnpm add --save-dev @babel/plugin-bugfix-firefox-class-in-computed-class-key
bun add --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"],
});