@babel/插件:修复火狐浏览器中计算类键内包含类的错误
非官方测试版翻译
本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →
此错误修复插件会转换其他类的计算键内的类,以解决 SpiderMonkey 错误中关于私有类元素的问题。
提示
该插件已包含在 @babel/preset-env 中,当你的编译目标(targets)受此浏览器错误影响时,Babel 会自动启用该插件。
警告
Terser 5.30.2 之前的版本会撤销此插件所做的转换。请确保使用至少 5.30.2 版本,或将 Terser 的 compress.inline 选项设为 false。
安装
- 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
用法
通过配置文件(推荐)
babel.config.json
{
"plugins": ["@babel/plugin-bugfix-firefox-class-in-computed-class-key"]
}
通过命令行
Shell
babel --plugins @babel/plugin-bugfix-firefox-class-in-computed-class-key script.js
通过 Node API
JavaScript
require("@babel/core").transformSync("code", {
plugins: ["@babel/plugin-bugfix-firefox-class-in-computed-class-key"],
});