@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.

bugfix-firefox-class-in-computed-class-key - 图1tip

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.

bugfix-firefox-class-in-computed-class-key - 图2warning

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
  • Yarn
  • pnpm
  1. npm install --save-dev @babel/plugin-bugfix-firefox-class-in-computed-class-key
  1. yarn add --dev @babel/plugin-bugfix-firefox-class-in-computed-class-key
  1. pnpm add --save-dev @babel/plugin-bugfix-firefox-class-in-computed-class-key

Usage

babel.config.json

  1. {
  2. "plugins": ["@babel/plugin-bugfix-firefox-class-in-computed-class-key"]
  3. }

Via CLI

Shell

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

Via Node API

JavaScript

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