From 4068b749ee61842c101519141748ccf5e050addf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Sun, 31 Mar 2024 10:56:56 +0200 Subject: [PATCH 1/4] Add docs for bugfix-firefox-class-in-computed-class-key --- ...fix-firefox-class-in-computed-class-key.md | 41 +++++++++++++++++++ 1 file changed, 41 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..9117ee3b69 --- /dev/null +++ b/docs/plugin-bugfix-firefox-class-in-computed-class-key.md @@ -0,0 +1,41 @@ +--- +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 optional chaining operators 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. +::: + +## 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"], +}); +``` From 7c8341570fbe43a7e99dde2f0b98351cf2e1bac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Wed, 3 Apr 2024 15:52:30 +0200 Subject: [PATCH 2/4] Mention terser --- docs/plugin-bugfix-firefox-class-in-computed-class-key.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/plugin-bugfix-firefox-class-in-computed-class-key.md b/docs/plugin-bugfix-firefox-class-in-computed-class-key.md index 9117ee3b69..0981ea7327 100644 --- a/docs/plugin-bugfix-firefox-class-in-computed-class-key.md +++ b/docs/plugin-bugfix-firefox-class-in-computed-class-key.md @@ -10,6 +10,10 @@ This bugfix plugin transforms optional chaining operators to workaround a [Spide 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 From d461a79b65dc3c32e66540a89b7dd7e42ecd9a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Wed, 3 Apr 2024 15:53:21 +0200 Subject: [PATCH 3/4] Add to sidebar --- website/sidebars.js | 1 + 1 file changed, 1 insertion(+) 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", ], From 942420b018cec349ebb2b3bc8aa97762957be571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Wed, 3 Apr 2024 17:29:01 +0200 Subject: [PATCH 4/4] Update docs/plugin-bugfix-firefox-class-in-computed-class-key.md --- docs/plugin-bugfix-firefox-class-in-computed-class-key.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/plugin-bugfix-firefox-class-in-computed-class-key.md b/docs/plugin-bugfix-firefox-class-in-computed-class-key.md index 0981ea7327..84082a515e 100644 --- a/docs/plugin-bugfix-firefox-class-in-computed-class-key.md +++ b/docs/plugin-bugfix-firefox-class-in-computed-class-key.md @@ -4,7 +4,7 @@ title: "@babel/plugin-bugfix-firefox-class-in-computed-class-key" sidebar_label: bugfix-firefox-class-in-computed-class-key --- -This bugfix plugin transforms optional chaining operators to workaround a [SpiderMonkey bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1887677) with private class elements. +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.