From 6678bf7d8d8ba5bb107246179c2beee58b1c7b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Wed, 3 Apr 2024 18:14:20 +0200 Subject: [PATCH] Add docs for bugfix-firefox-class-in-computed-class-key (#2885) --- ...fix-firefox-class-in-computed-class-key.md | 45 +++++++++++++++++++ website/sidebars.js | 1 + 2 files changed, 46 insertions(+) create mode 100644 docs/plugin-bugfix-firefox-class-in-computed-class-key.md diff --git a/docs/plugin-bugfix-firefox-class-in-computed-class-key.md b/docs/plugin-bugfix-firefox-class-in-computed-class-key.md new file mode 100644 index 0000000000..84082a515e --- /dev/null +++ b/docs/plugin-bugfix-firefox-class-in-computed-class-key.md @@ -0,0 +1,45 @@ +--- +id: babel-plugin-bugfix-firefox-class-in-computed-class-key +title: "@babel/plugin-bugfix-firefox-class-in-computed-class-key" +sidebar_label: bugfix-firefox-class-in-computed-class-key +--- + +This bugfix plugin transforms classes inside computed keys of other classes to workaround a [SpiderMonkey bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1887677) with private class elements. + +:::tip +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. +::: + +:::warning +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`](https://terser.org/docs/options/#compress-options) option to `false`. +::: + +## Installation + +```shell npm2yarn +npm install --save-dev @babel/plugin-bugfix-firefox-class-in-computed-class-key +``` + +## Usage + +### With a configuration file (Recommended) + +```json title="babel.config.json" +{ + "plugins": ["@babel/plugin-bugfix-firefox-class-in-computed-class-key"] +} +``` + +### Via CLI + +```sh title="Shell" +babel --plugins @babel/plugin-bugfix-firefox-class-in-computed-class-key script.js +``` + +### Via Node API + +```js title="JavaScript" +require("@babel/core").transformSync("code", { + plugins: ["@babel/plugin-bugfix-firefox-class-in-computed-class-key"], +}); +``` diff --git a/website/sidebars.js b/website/sidebars.js index 13f4eec001..f4c6a258da 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -152,6 +152,7 @@ module.exports = { type: "category", label: "Bugfix", items: [ + "babel-plugin-bugfix-firefox-class-in-computed-class-key", "babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression", "babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining", ],