Skip to content

Commit 024e9c3

Browse files
committed
Add docs for plugin-bugfix-safari-class-field-initializer-scope
See babel/babel#16569 Doc structure adapted from `plugin-bugfix-firefox-class-in-computed-class-key`
1 parent 97be67f commit 024e9c3

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
id: babel-plugin-bugfix-safari-class-field-initializer-scope
3+
title: "@babel/plugin-bugfix-safari-class-field-initializer-scope"
4+
sidebar_label: bugfix-safari-class-field-initializer-scope
5+
---
6+
7+
This bugfix plugin wraps some class field initializers with an IIFE to workaround [a WebKit bug](https://webkit.org/b/236843) which affects Safari 15.
8+
9+
:::tip
10+
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.
11+
:::
12+
13+
## Installation
14+
15+
```shell npm2yarn
16+
npm install --save-dev @babel/plugin-bugfix-safari-class-field-initializer-scope
17+
```
18+
19+
## Usage
20+
21+
### With a configuration file (Recommended)
22+
23+
```json title="babel.config.json"
24+
{
25+
"plugins": ["@babel/plugin-bugfix-safari-class-field-initializer-scope"]
26+
}
27+
```
28+
29+
### Via CLI
30+
31+
```sh title="Shell"
32+
babel --plugins @babel/plugin-bugfix-safari-class-field-initializer-scope script.js
33+
```
34+
35+
### Via Node API
36+
37+
```js title="JavaScript"
38+
require("@babel/core").transformSync("code", {
39+
plugins: ["@babel/plugin-bugfix-safari-class-field-initializer-scope"],
40+
});
41+
```

0 commit comments

Comments
 (0)