Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions docs/standalone.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,32 @@ See [here](https://github.com/babel/babel/blob/main/packages/babel-standalone/sr

If you want to add custom plugins, refer to the [custom plugins](#custom-plugins) section.

#### `data-targets`

Added in: `v7.29.0`

Use the `data-targets` attribute to specify the [compilation targets](./options.md#targets) of the project.

:::babel7

By default Babel will transpile all features down to ES3 supported by IE 8 and other legacy browsers. You can specify the [browserslist](https://github.com/browserslist/browserslist#queries) [`defaults`](https://browsersl.ist/#q=defaults) query, which covers most modern browsers. This will be the Babel 8 default target.

```html
<script type="text/babel" data-presets="env" data-targets="defaults">
```

:::

:::babel8

By default Babel will transpile all features to the [browserslist](https://github.com/browserslist/browserslist#queries) [`defaults`](https://browsersl.ist/#q=defaults) targets, which covers most modern browsers. If you want to support legacy browsers such as IE 8, you must specify the this attribute:

```html
<script type="text/babel" data-presets="env" data-targets="ie 8">
```

:::

#### `src`
Loading external scripts via `src` attribute is supported too:

Expand Down
10 changes: 10 additions & 0 deletions docs/v8-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -690,3 +690,13 @@ Make sure to also check the [@babel/plugin-transform-flow-strip-types](#babel-pl
```
babel-node --flag-for-node --flag-for-babel script.js --flag-for-script
```

### `@babel/standalone` {#babel-standalone}

![high](https://img.shields.io/badge/risk%20of%20breakage%3F-high-red.svg)

- Use browserslist's `defaults` as default compilation target ([#12989](https://github.com/babel/babel/pull/12989), [#15551](https://github.com/babel/babel/pull/15551)).

If you are already using the `data-targets` attribute, this change won't affect you.

**Migration**: You'll probably be fine with the new behavior since the [browserslist's `defaults` covers most modern browsers](https://browsersl.ist/#q=defaults). If you need to support legacy browsers, specify the [`data-targets`](./standalone.md#data-targets) attribute.