[skip ci] removed shorthand usage of official babel scoped presets & plugins from README.md's (#6820)

This commit is contained in:
Steven Hargrove 2017-11-16 22:51:23 -05:00 committed by Henry Zhu
parent 39dae28d5c
commit cee9ae48e0
101 changed files with 381 additions and 381 deletions

View File

@ -115,7 +115,7 @@ $ TEST_ONLY=babel-cli make test
`TEST_ONLY` will also match substrings of the package name:
```sh
# Run tests for the babel-plugin-transform-classes package.
# Run tests for the @babel/plugin-transform-classes package.
$ TEST_ONLY=es2015-class make test
```
@ -161,16 +161,16 @@ In case you're locally getting errors which are not on the CI, it may be due to
Most packages in [`/packages`](https://github.com/babel/babel/tree/master/packages) have a `test` folder, however some tests might be in other packages or in [`/packages/babel-core`](https://github.com/babel/babel/tree/master/packages/babel-core/test/fixtures).
#### `babel-plugin-x`
#### `@babel/plugin-x`
All the Babel plugins (and other packages) that have a `/test/fixtures` are written in a similar way.
For example, in [`babel-plugin-transform-exponentiation-operator/test`](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-exponentiation-operator/test):
For example, in [`@babel/plugin-transform-exponentiation-operator/test`](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-exponentiation-operator/test):
- There is an `index.js` file. It imports our [test helper](https://github.com/babel/babel/tree/master/packages/babel-helper-plugin-test-runner). (You don't have to worry about this).
- There can be multiple folders under [`/fixtures`](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures)
- There is an [`options.json`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/options.json) file whose function is similar to a `.babelrc` file, allowing you to pass in the plugins and settings you need for your tests.
- For this test, we only need the relevant plugin, so it's just `{ "plugins": ["@babel/transform-exponentiation-operator"] }`.
- For this test, we only need the relevant plugin, so it's just `{ "plugins": ["@babel/plugin-transform-exponentiation-operator"] }`.
- If necessary, you can have an `options.json` with different options in each subfolder.
- In each subfolder, you can organize your directory structure by categories of tests. (Example: these folders can be named after the feature you are testing or can reference the issue number they fix)
@ -205,8 +205,8 @@ If you need to check for an error that is thrown you can add to the `options.jso
```js
// options.json example
{
"plugins": [["@babel/proposal-object-rest-spread", { "useBuiltIns": "invalidOption" }]],
"throws": "@babel/proposal-object-rest-spread currently only accepts a boolean option for useBuiltIns (defaults to false)"
"plugins": [["@babel/plugin-proposal-object-rest-spread", { "useBuiltIns": "invalidOption" }]],
"throws": "@babel/plugin-proposal-object-rest-spread currently only accepts a boolean option for useBuiltIns (defaults to false)"
}
```
@ -233,7 +233,7 @@ descriptive name, and add the following:
#### Bootstrapping expected output
For both `babel-plugin-x` and `babylon`, you can easily generate an `expected.js`/`expected.json` automatically by just providing `actual.js` and running the tests as you usually would.
For both `@babel/plugin-x` and `babylon`, you can easily generate an `expected.js`/`expected.json` automatically by just providing `actual.js` and running the tests as you usually would.
```
// Example
@ -267,7 +267,7 @@ To include the changes, we have to make sure to build Babel:
$ make build
```
Next, we need to execute `Generator.generate()`, which can be achieved by running a test case in the `babel-generator` package.
Next, we need to execute `Generator.generate()`, which can be achieved by running a test case in the `@babel/generator` package.
For example, we can run the test case that tests the generation of class declarations:
```bash

View File

@ -36,21 +36,21 @@ npm install --save-dev @babel/plugin-codemod-optional-catch-binding
```json
{
"plugins": ["@babel/codemod-optional-catch-binding"]
"plugins": ["@babel/plugin-codemod-optional-catch-binding"]
}
```
### Via CLI
```sh
babel --plugins @babel/codemod-optional-catch-binding script.js
babel --plugins @babel/plugin-codemod-optional-catch-binding script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/codemod-optional-catch-binding"]
plugins: ["@babel/plugin-codemod-optional-catch-binding"]
});
```

View File

@ -262,7 +262,7 @@ This release primarily upgrades `compat-table`, which adds support for async on
- Add tests for debug output ([#156](https://github.com/babel/babel-preset-env/pull/156)) (@existentialism)
Since we've (mostly @yavorsky) have fixed a number of bugs recently with the `debug` option output, we added the ability to assert stdout matches what we expect. Read the updated [CONTRIBUTING.md](https://github.com/babel/babel-preset-env/blob/master/CONTRIBUTING.md#testing-the-debug-option) for more info.
Since we've (mostly @yavorsky) have fixed a number of bugs recently with the `debug` option output, we added the ability to assert stdout matches what we expect. Read the updated [CONTRIBUTING.md](https://github.com/babel/experimental/babel-preset-env/blob/master/CONTRIBUTING.md#testing-the-debug-option) for more info.
- Fixes #143. Log correct targets. ([#155](https://github.com/babel/babel-preset-env/pull/155)) (@yavorsky)
@ -442,7 +442,7 @@ Example:
`"exclude": ["map"]` doesn't include the `Map` polyfill if you know you aren't using it in your code (w/ `useBuiltIns`). (We will figure out a way to automatically do this [#84](https://github.com/babel/babel-preset-env/issues/84)).
If you pass a wrong plugin it will error: valid options for `include/exclude` are in [/data/plugin-features.js](https://github.com/babel/babel-preset-env/blob/master/data/plugin-features.js) and [/data/built-in-features.js](https://github.com/babel/babel-preset-env/blob/master/data/built-in-features.js) (without the `es6.`)
If you pass a wrong plugin it will error: valid options for `include/exclude` are in [/data/plugin-features.js](https://github.com/babel/experimental/babel-preset-env/blob/master/data/plugin-features.js) and [/data/built-in-features.js](https://github.com/babel/experimental/babel-preset-env/blob/master/data/built-in-features.js) (without the `es6.`)
### :house: Internal
@ -555,7 +555,7 @@ Electron is also an environment, so [Paul went ahead](https://twitter.com/paulcb
}
```
> Currently we are manually updating the data in [/data/electron-to-chromium.js](https://github.com/babel/babel-preset-env/blob/master/data/electron-to-chromium.js), but [@kevinsawicki](https://github.com/kevinsawicki) says we could generate the data from [atom-shell/dist/index.json](https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist/index.json) as well! (Someone should make a PR :smile:)
> Currently we are manually updating the data in [/data/electron-to-chromium.js](https://github.com/babel/experimental/babel-preset-env/blob/master/data/electron-to-chromium.js), but [@kevinsawicki](https://github.com/kevinsawicki) says we could generate the data from [atom-shell/dist/index.json](https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist/index.json) as well! (Someone should make a PR :smile:)

View File

@ -2,7 +2,7 @@
## Adding a new plugin to support (when approved in the next ECMAScript version)
### Update [`plugin-features.js`](https://github.com/babel/babel-preset-env/blob/master/data/plugin-features.js)
### Update [`plugin-features.js`](https://github.com/babel/babel/blob/master/experimental/babel-preset-env/data/plugin-features.js)
*Example:*
@ -14,20 +14,20 @@ Find the relevant entries on [compat-table](https://kangax.github.io/compat-tabl
Find the corresponding babel plugin:
`transform-exponentiation-operator`
`@babel/plugin-transform-exponentiation-operator`
And add them in this structure:
```js
// es2016
"@babel/transform-exponentiation-operator": {
"@babel/plugin-transform-exponentiation-operator": {
features: [
"exponentiation (**) operator",
],
},
```
### Update [`built-in-features.js`](https://github.com/babel/babel-preset-env/blob/master/data/built-in-features.js)
### Update [`built-in-features.js`](https://github.com/babel/babel/blob/master/experimental/babel-preset-env/data/built-in-features.js)
*Example:*
@ -42,7 +42,7 @@ Find the corresponding module on [core-js](https://github.com/zloirock/core-js/t
`es7.object.values.js`
Find required ES version in [`built-in-features.js`](https://github.com/babel/babel-preset-env/blob/master/data/built-in-features.js) and add the new feature:
Find required ES version in [`built-in-features.js`](https://github.com/babel/babel/blob/master/experimental/babel-preset-env/data/built-in-features.js) and add the new feature:
```js
const es2017 = {
@ -51,7 +51,7 @@ const es2017 = {
}
```
### Update [`plugins.json`](https://github.com/babel/babel-preset-env/blob/master/data/plugins.json)
### Update [`plugins.json`](https://github.com/babel/babel/blob/master/experimental/babel-preset-env/data/plugins.json)
Until `compat-table` is a standalone npm module for data we are using the git url
@ -77,7 +77,7 @@ npm run coverage
#### General
All the tests for `babel-preset-env` exist in the `test/fixtures` folder. The
All the tests for `@babel/preset-env` exist in the `test/fixtures` folder. The
test setup and conventions are exactly the same as testing a Babel plugin, so
please read our [documentation on writing tests](https://github.com/babel/babel/blob/master/CONTRIBUTING.md#babel-plugin-x).

View File

@ -10,7 +10,7 @@ Without any configuration options, @babel/preset-env behaves exactly the same as
```json
{
"presets": ["@babel/env"]
"presets": ["@babel/preset-env"]
}
```
@ -21,7 +21,7 @@ This example only includes the polyfills and code transforms needed for the last
```json
{
"presets": [
["@babel/env", {
["@babel/preset-env", {
"targets": {
"browsers": ["last 2 versions", "safari >= 7"]
}
@ -30,12 +30,12 @@ This example only includes the polyfills and code transforms needed for the last
}
```
Similarly, if you're targeting Node.js instead of the browser, you can configure babel-preset-env to only include the polyfills and transforms necessary for a particular version:
Similarly, if you're targeting Node.js instead of the browser, you can configure @babel/preset-env to only include the polyfills and transforms necessary for a particular version:
```json
{
"presets": [
["@babel/env", {
["@babel/preset-env", {
"targets": {
"node": "6.10"
}
@ -49,7 +49,7 @@ For convenience, you can use `"node": "current"` to only include the necessary p
```json
{
"presets": [
["@babel/env", {
["@babel/preset-env", {
"targets": {
"node": "current"
}
@ -73,13 +73,13 @@ Use external data such as [`compat-table`](https://github.com/kangax/compat-tabl
![](https://cloud.githubusercontent.com/assets/588473/19214029/58deebce-8d48-11e6-9004-ee3fbcb75d8b.png)
We can periodically run [build-data.js](https://github.com/babel/babel-preset-env/blob/master/scripts/build-data.js) which generates [plugins.json](https://github.com/babel/babel-preset-env/blob/master/data/plugins.json).
We can periodically run [build-data.js](https://github.com/babel/experimental/babel-preset-env/blob/master/scripts/build-data.js) which generates [plugins.json](https://github.com/babel/experimental/babel-preset-env/blob/master/data/plugins.json).
Ref: [#7](https://github.com/babel/babel-preset-env/issues/7)
### Maintain a mapping between JavaScript features and Babel plugins
> Currently located at [plugin-features.js](https://github.com/babel/babel-preset-env/blob/master/data/plugin-features.js).
> Currently located at [plugin-features.js](https://github.com/babel/experimental/babel-preset-env/blob/master/data/plugin-features.js).
This should be straightforward to do in most cases. There might be cases where plugins should be split up more or certain plugins aren't standalone enough (or impossible to do).
@ -117,7 +117,7 @@ For example, to enable only the polyfills and plugins needed for a project targe
```json
{
"presets": [
["@babel/env", {
["@babel/preset-env", {
"useBuiltIns": "entry"
}]
]
@ -167,7 +167,7 @@ The default behavior without options runs all transforms (behaves the same as [@
```json
{
"presets": ["@babel/env"]
"presets": ["@babel/preset-env"]
}
```
@ -185,7 +185,7 @@ Each target environment takes a number or a string (we recommend using a string
Example environments: `chrome`, `opera`, `edge`, `firefox`, `safari`, `ie`, `ios`, `android`, `node`, `electron`.
The [data](https://github.com/babel/babel-preset-env/blob/master/data/plugins.json) for this is generated by running the [build-data script](https://github.com/babel/babel-preset-env/blob/master/scripts/build-data.js) which pulls in data from [compat-table](https://kangax.github.io/compat-table).
The [data](https://github.com/babel/experimental/babel-preset-env/blob/master/data/plugins.json) for this is generated by running the [build-data script](https://github.com/babel/experimental/babel-preset-env/blob/master/scripts/build-data.js) which pulls in data from [compat-table](https://kangax.github.io/compat-table).
### `targets.node`
@ -225,7 +225,7 @@ Setting this to `false` will not transform modules.
`boolean`, defaults to `false`.
Outputs the targets/plugins used and the version specified in [plugin data version](https://github.com/babel/babel-preset-env/blob/master/data/plugins.json) to `console.log`.
Outputs the targets/plugins used and the version specified in [plugin data version](https://github.com/babel/experimental/babel-preset-env/blob/master/data/plugins.json) to `console.log`.
### `include`
@ -235,15 +235,15 @@ An array of plugins to always include.
Valid options include any:
- [Babel plugins](https://github.com/babel/babel-preset-env/blob/master/data/plugin-features.js), names without a prefix like `transform-spread` instead of `plugin-transform-spread` are supported. Note, that none of the module transforms (`transform-module-*`) are supported here, use the [`modules` option](https://github.com/babel/babel/tree/master/experimental/babel-preset-env#modules) instead.
- [Babel plugins](https://github.com/babel/experimental/babel-preset-env/blob/master/data/plugin-features.js) - both with (`@babel/plugin-transform-spread`) and without prefix (`plugin-transform-spread`) are supported.
- [Built-ins](https://github.com/babel/babel-preset-env/blob/master/data/built-in-features.js), such as `map`, `set`, or `object.assign`.
- [Built-ins](https://github.com/babel/experimental/babel-preset-env/blob/master/data/built-in-features.js), such as `map`, `set`, or `object.assign`.
This option is useful if there is a bug in a native implementation, or a combination of a non-supported feature + a supported one doesn't work.
For example, Node 4 supports native classes but not spread. If `super` is used with a spread argument, then the `transform-classes` transform needs to be `include`d, as it is not possible to transpile a spread with `super` otherwise.
For example, Node 4 supports native classes but not spread. If `super` is used with a spread argument, then the `@babel/plugin-transform-classes` transform needs to be `include`d, as it is not possible to transpile a spread with `super` otherwise.
> NOTE: The `include` and `exclude` options _only_ work with the [plugins included with this preset](https://github.com/babel/babel-preset-env/blob/master/data/plugin-features.js); so, for example, including `proposal-do-expressions` or excluding `proposal-function-bind` will throw errors. To use a plugin _not_ included with this preset, add them to your [config](https://babeljs.io/docs/usage/babelrc/) directly.
> NOTE: The `include` and `exclude` options _only_ work with the [plugins included with this preset](https://github.com/babel/experimental/babel-preset-env/blob/master/data/plugin-features.js); so, for example, including `@babel/plugin-proposal-do-expressions` or excluding `@babel/plugin-proposal-function-bind` will throw errors. To use a plugin _not_ included with this preset, add them to your [config](https://babeljs.io/docs/usage/babelrc/) directly.
### `exclude`
@ -253,7 +253,7 @@ An array of plugins to always exclude/remove.
The possible options are the same as the `include` option.
This option is useful for "blacklisting" a transform like `transform-regenerator` if you don't use generators and don't want to include `regeneratorRuntime` (when using `useBuiltIns`) or for using another plugin like [fast-async](https://github.com/MatAtBread/fast-async) instead of [Babel's async-to-gen](http://babeljs.io/docs/plugins/proposal-async-generator-functions/).
This option is useful for "blacklisting" a transform like `@babel/plugin-transform-regenerator` if you don't use generators and don't want to include `regeneratorRuntime` (when using `useBuiltIns`) or for using another plugin like [fast-async](https://github.com/MatAtBread/fast-async) instead of [Babel's async-to-gen](http://babeljs.io/docs/plugins/proposal-async-generator-functions/).
### `useBuiltIns`
@ -342,7 +342,7 @@ Don't add polyfills automatically per file, or transform `import "@babel/polyfil
```js
module.exports = {
presets: [
["@babel/env", {
["@babel/preset-env", {
targets: {
chrome: 59,
edge: 13,
@ -419,7 +419,7 @@ export class A {}
```json
{
"presets": [
["@babel/env", {
["@babel/preset-env", {
"targets": {
"chrome": 52
}
@ -442,7 +442,7 @@ exports.A = A;
```json
{
"presets": [
["@babel/env", {
["@babel/preset-env", {
"targets": {
"chrome": 52
},
@ -466,7 +466,7 @@ export class A {}
```json
{
"presets": [
["@babel/env", {
["@babel/preset-env", {
"targets": {
"chrome": 52,
"browsers": ["last 2 versions", "safari 7"]
@ -491,7 +491,7 @@ export var A = function A() {
```json
{
"presets": [
["@babel/env", {
["@babel/preset-env", {
"targets": {
"node": "current"
}
@ -514,7 +514,7 @@ exports.A = A;
```json
{
"presets": [
["@babel/env", {
["@babel/preset-env", {
"targets": {
"safari": 10
},
@ -537,8 +537,8 @@ Using targets:
Modules transform: false
Using plugins:
transform-exponentiation-operator {}
transform-async-to-generator {}
@babel/plugin-transform-exponentiation-operator {}
@babel/plugin-transform-async-to-generator {}
Using polyfills:
es7.object.values {}
@ -556,12 +556,12 @@ Using polyfills:
```json
{
"presets": [
["@babel/env", {
["@babel/preset-env", {
"targets": {
"browsers": ["last 2 versions", "safari >= 7"]
},
"include": ["transform-arrow-functions", "es6.map"],
"exclude": ["transform-regenerator", "es6.set"]
"include": ["@babel/plugin-transform-arrow-functions", "es6.map"],
"exclude": ["@babel/plugin-transform-regenerator", "es6.set"]
}]
]
}

View File

@ -45,7 +45,7 @@ Check out the [`babel-handbook`](https://github.com/thejameskyle/babel-handbook/
| [`@babel/helpers`](/packages/babel-helpers) | [![npm](https://img.shields.io/npm/v/babel-helpers.svg?maxAge=2592000)](https://www.npmjs.com/package/babel-helpers) | [![Dependency Status](https://david-dm.org/babel/babel.svg?path=packages/babel-helpers)](https://david-dm.org/babel/babel?path=packages/babel-helpers) |
| [`@babel/code-frame`](/packages/babel-code-frame) | [![npm](https://img.shields.io/npm/v/babel-code-frame.svg?maxAge=2592000)](https://www.npmjs.com/package/babel-code-frame) | [![Dependency Status](https://david-dm.org/babel/babel.svg?path=packages/babel-code-frame)](https://david-dm.org/babel/babel?path=packages/babel-code-frame) |
- [`@babel/cli`](/packages/babel-cli) is the CLI tool that runs `@babel/core` and helps with outputting to a directory, a file, stdout and more (also includes `babel-node`). Check out the [docs](https://babeljs.io/docs/usage/cli/).
- [`@babel/cli`](/packages/babel-cli) is the CLI tool that runs `@babel/core` and helps with outputting to a directory, a file, stdout and more (also includes `@babel/node` cli). Check out the [docs](https://babeljs.io/docs/usage/cli/).
- [`@babel/types`](/packages/babel-types) is used to validate, build and change AST nodes.
- [`@babel/polyfill`](/packages/babel-polyfill) is [literally a wrapper](https://github.com/babel/babel/blob/master/packages/babel-polyfill/src/index.js) around [`core-js`](https://github.com/zloirock/core-js) and [regenerator-runtime](https://github.com/facebook/regenerator/tree/master/packages/regenerator-runtime). Check out the [docs](https://babeljs.io/docs/usage/polyfill/).
- [`@babel/runtime`](/packages/babel-runtime) is similar to the polyfill except that it doesn't modify the global scope and is to be used with [`@babel/plugin-transform-runtime`](/packages/babel-plugin-transform-runtime) (usually in library/plugin code). Check out the [docs](https://babeljs.io/docs/plugins/transform-runtime/).

View File

@ -55,4 +55,4 @@ require("@babel/core").transform("code", {
## Note
This check will only validate consts. If you need it to compile down to `var` then you must also install and enable [`transform-block-scoping`](http://babeljs.io/docs/plugins/transform-block-scoping/).
This check will only validate consts. If you need it to compile down to `var` then you must also install and enable [`@babel/plugin-transform-block-scoping`](http://babeljs.io/docs/plugins/transform-block-scoping/).

View File

@ -14,20 +14,20 @@ npm install --save-dev @babel/plugin-external-helpers
```json
{
"plugins": ["@babel/external-helpers"]
"plugins": ["@babel/plugin-external-helpers"]
}
```
### Via CLI
```sh
babel --plugins @babel/external-helpers script.js
babel --plugins @babel/plugin-external-helpers script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/external-helpers"]
plugins: ["@babel/plugin-external-helpers"]
});
```

View File

@ -84,21 +84,21 @@ npm install --save-dev @babel/plugin-proposal-async-generator-functions
```json
{
"plugins": ["@babel/proposal-async-generator-functions"]
"plugins": ["@babel/plugin-proposal-async-generator-functions"]
}
```
### Via CLI
```sh
babel --plugins @babel/proposal-async-generator-functions script.js
babel --plugins @babel/plugin-proposal-async-generator-functions script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/proposal-async-generator-functions"]
plugins: ["@babel/plugin-proposal-async-generator-functions"]
});
```

View File

@ -50,7 +50,7 @@ Without options:
```json
{
"plugins": ["@babel/proposal-class-properties"]
"plugins": ["@babel/plugin-proposal-class-properties"]
}
```
@ -59,7 +59,7 @@ With options:
```json
{
"plugins": [
["@babel/proposal-class-properties", { "loose": true }]
["@babel/plugin-proposal-class-properties", { "loose": true }]
]
}
```
@ -67,14 +67,14 @@ With options:
### Via CLI
```sh
babel --plugins @babel/proposal-class-properties script.js
babel --plugins @babel/plugin-proposal-class-properties script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/proposal-class-properties"]
plugins: ["@babel/plugin-proposal-class-properties"]
});
```

View File

@ -58,23 +58,23 @@ Add the following line to your .babelrc file:
```json
{
"plugins": ["@babel/proposal-decorators"]
"plugins": ["@babel/plugin-proposal-decorators"]
}
```
#### NOTE: Order of Plugins Matters!
If you are including your plugins manually and using `proposal-class-properties`, make sure that `proposal-decorators` comes *before* `proposal-class-properties`.
If you are including your plugins manually and using `@babel/plugin-proposal-class-properties`, make sure that `@babel/plugin-proposal-decorators` comes *before* `@babel/plugin-proposal-class-properties`.
Currently, `proposal-class-properties` must be used in `loose` mode to support the `proposal-decorators`. To use `proposal-class-properties` in spec mode with decorators, wait for the next major version of decorators (Stage 2).
Currently, `@babel/plugin-proposal-class-properties` must be used in `loose` mode to support the `@babel/plugin-proposal-decorators`. To use `@babel/plugin-proposal-class-properties` in spec mode with decorators, wait for the next major version of decorators (Stage 2).
Wrong:
```json
{
"plugins": [
"@babel/proposal-class-properties",
"@babel/proposal-decorators"
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-decorators"
]
}
```
@ -84,8 +84,8 @@ Right:
```json
{
"plugins": [
"@babel/proposal-decorators",
["@babel/proposal-class-properties", { "loose" : true }]
"@babel/plugin-proposal-decorators",
["@babel/plugin-proposal-class-properties", { "loose" : true }]
]
}
```
@ -93,14 +93,14 @@ Right:
### Via CLI
```sh
babel --plugins @babel/proposal-decorators script.js
babel --plugins @babel/plugin-proposal-decorators script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/proposal-decorators"]
plugins: ["@babel/plugin-proposal-decorators"]
});
```

View File

@ -94,21 +94,21 @@ npm install --save-dev @babel/plugin-proposal-do-expressions
```json
{
"plugins": ["@babel/proposal-do-expressions"]
"plugins": ["@babel/plugin-proposal-do-expressions"]
}
```
### Via CLI
```sh
babel --plugins @babel/proposal-do-expressions script.js
babel --plugins @babel/plugin-proposal-do-expressions script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/proposal-do-expressions"]
plugins: ["@babel/plugin-proposal-do-expressions"]
});
```

View File

@ -22,21 +22,21 @@ npm install --save-dev @babel/plugin-proposal-export-default
```json
{
"plugins": ["@babel/proposal-export-default"]
"plugins": ["@babel/plugin-proposal-export-default"]
}
```
### Via CLI
```sh
babel --plugins @babel/proposal-export-default script.js
babel --plugins @babel/plugin-proposal-export-default script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/proposal-export-default"]
plugins: ["@babel/plugin-proposal-export-default"]
});
```
## References

View File

@ -22,21 +22,21 @@ npm install --save-dev @babel/plugin-proposal-export-namespace
```json
{
"plugins": ["@babel/proposal-export-namespace"]
"plugins": ["@babel/plugin-proposal-export-namespace"]
}
```
### Via CLI
```sh
babel --plugins @babel/proposal-export-namespace script.js
babel --plugins @babel/plugin-proposal-export-namespace script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/proposal-export-namespace"]
plugins: ["@babel/plugin-proposal-export-namespace"]
});
```
## References

View File

@ -97,21 +97,21 @@ npm install --save-dev @babel/plugin-proposal-function-bind
```json
{
"plugins": ["@babel/proposal-function-bind"]
"plugins": ["@babel/plugin-proposal-function-bind"]
}
```
### Via CLI
```sh
babel --plugins @babel/proposal-function-bind script.js
babel --plugins @babel/plugin-proposal-function-bind script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/proposal-function-bind"]
plugins: ["@babel/plugin-proposal-function-bind"]
});
```

View File

@ -43,21 +43,21 @@ npm install --save-dev @babel/plugin-proposal-function-sent
```json
{
"plugins": ["@babel/proposal-function-sent"]
"plugins": ["@babel/plugin-proposal-function-sent"]
}
```
### Via CLI
```sh
babel --plugins @babel/proposal-function-sent script.js
babel --plugins @babel/plugin-proposal-function-sent script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/proposal-function-sent"]
plugins: ["@babel/plugin-proposal-function-sent"]
});
```

View File

@ -35,21 +35,21 @@ npm install --save-dev @babel/plugin-proposal-nullish-coalescing-operator
```json
{
"plugins": ["@babel/proposal-nullish-coalescing-operator"]
"plugins": ["@babel/plugin-proposal-nullish-coalescing-operator"]
}
```
### Via CLI
```sh
babel --plugins @babel/proposal-nullish-coalescing-operator script.js
babel --plugins @babel/plugin-proposal-nullish-coalescing-operator script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/proposal-nullish-coalescing-operator"]
plugins: ["@babel/plugin-proposal-nullish-coalescing-operator"]
});
```

View File

@ -71,29 +71,29 @@ npm install --save-dev @babel/plugin-proposal-numeric-separator
```json
{
"plugins": ["@babel/proposal-numeric-separator"]
"plugins": ["@babel/plugin-proposal-numeric-separator"]
}
```
### Via CLI
```sh
babel --plugins @babel/proposal-numeric-separator script.js
babel --plugins @babel/plugin-proposal-numeric-separator script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/proposal-numeric-separator"]
plugins: ["@babel/plugin-proposal-numeric-separator"]
});
```
## Additional Information
If you need to further compile ES2015 Decimal, Binary, Hex and Octal number representations to their pre-ES2015 numeric literal form, add the [`"@babel/transform-literals"`](http://babeljs.io/docs/plugins/transform-literals/) plugin:
If you need to further compile ES2015 Decimal, Binary, Hex and Octal number representations to their pre-ES2015 numeric literal form, add the [`"@babel/plugin-transform-literals"`](http://babeljs.io/docs/plugins/transform-literals/) plugin:
> `transform-literals` is already included in [@babel/preset-env](https://github.com/babel/babel/tree/master/experimental/babel-preset-env) and @babel/preset-es2015.
> `@babel/plugin-transform-literals` is already included in [@babel/preset-env](https://github.com/babel/babel/tree/master/experimental/babel-preset-env) and @babel/preset-es2015.
### Via `.babelrc` (Recommended)
@ -101,11 +101,11 @@ If you need to further compile ES2015 Decimal, Binary, Hex and Octal number repr
```json
{
"presets": ["@babel/env"],
"plugins": ["@babel/proposal-numeric-separator"]
"presets": ["@babel/preset-env"],
"plugins": ["@babel/plugin-proposal-numeric-separator"]
}
{
"plugins": ["@babel/proposal-numeric-separator", "@babel/transform-literals"]
"plugins": ["@babel/plugin-proposal-numeric-separator", "@babel/plugin-transform-literals"]
}
```

View File

@ -34,21 +34,21 @@ npm install --save-dev @babel/plugin-proposal-object-rest-spread
```json
{
"plugins": ["@babel/proposal-object-rest-spread"]
"plugins": ["@babel/plugin-proposal-object-rest-spread"]
}
```
### Via CLI
```sh
babel --plugins @babel/proposal-object-rest-spread script.js
babel --plugins @babel/plugin-proposal-object-rest-spread script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/proposal-object-rest-spread"]
plugins: ["@babel/plugin-proposal-object-rest-spread"]
});
```
@ -65,7 +65,7 @@ By default, this plugin uses Babel's `extends` helper which polyfills `Object.as
```json
{
"plugins": [
["@babel/proposal-object-rest-spread", { "useBuiltIns": true }]
["@babel/plugin-proposal-object-rest-spread", { "useBuiltIns": true }]
]
}
```

View File

@ -38,21 +38,21 @@ npm install --save-dev @babel/plugin-proposal-optional-catch-binding
```json
{
"plugins": ["@babel/proposal-optional-catch-binding"]
"plugins": ["@babel/plugin-proposal-optional-catch-binding"]
}
```
### Via CLI
```sh
babel --plugins @babel/proposal-optional-catch-binding script.js
babel --plugins @babel/plugin-proposal-optional-catch-binding script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/proposal-optional-catch-binding"]
plugins: ["@babel/plugin-proposal-optional-catch-binding"]
});
```

View File

@ -95,21 +95,21 @@ npm install --save-dev @babel/plugin-proposal-optional-chaining
```json
{
"plugins": ["@babel/proposal-optional-chaining"]
"plugins": ["@babel/plugin-proposal-optional-chaining"]
}
```
### Via CLI
```sh
babel --plugins @babel/proposal-optional-chaining script.js
babel --plugins @babel/plugin-proposal-optional-chaining script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/proposal-optional-chaining"]
plugins: ["@babel/plugin-proposal-optional-chaining"]
});
```

View File

@ -16,20 +16,20 @@ $ npm install @babel/plugin-proposal-pipeline-operator
```json
{
"plugins": ["@babel/proposal-pipeline-operator"]
"plugins": ["@babel/plugin-proposal-pipeline-operator"]
}
```
### Via CLI
```sh
$ babel --plugins @babel/proposal-pipeline-operator script.js
$ babel --plugins @babel/plugin-proposal-pipeline-operator script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/proposal-pipeline-operator"]
plugins: ["@babel/plugin-proposal-pipeline-operator"]
});
```

View File

@ -24,21 +24,21 @@ npm install --save-dev @babel/plugin-proposal-throw-expressions
```json
{
"plugins": ["@babel/proposal-throw-expressions"]
"plugins": ["@babel/plugin-proposal-throw-expressions"]
}
```
### Via CLI
```sh
babel --plugins @babel/proposal-throw-expressions script.js
babel --plugins @babel/plugin-proposal-throw-expressions script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/proposal-throw-expressions"]
plugins: ["@babel/plugin-proposal-throw-expressions"]
});
```

View File

@ -20,21 +20,21 @@ npm install @babel/plugin-proposal-unicode-property-regex
```json
{
"plugins": ["@babel/proposal-unicode-property-regex"]
"plugins": ["@babel/plugin-proposal-unicode-property-regex"]
}
```
### Via CLI
```sh
babel --plugins @babel/@babel/proposal-unicode-property-regex script.js
babel --plugins @babel/@babel/plugin-proposal-unicode-property-regex script.js
```
### Via Node.js API
```js
require("@babel/core").transform(code, {
"plugins": ["@babel/proposal-unicode-property-regex"]
"plugins": ["@babel/plugin-proposal-unicode-property-regex"]
});
```
@ -43,7 +43,7 @@ To transpile to ES6/ES2015:
```js
require("@babel/core").transform(code, {
"plugins": [
["@babel/proposal-unicode-property-regex", { "useUnicodeFlag": false }]
["@babel/plugin-proposal-unicode-property-regex", { "useUnicodeFlag": false }]
]
});
```

View File

@ -34,21 +34,21 @@ npm install --save-dev @babel/plugin-syntax-async-generators
```json
{
"plugins": ["@babel/syntax-async-generators"]
"plugins": ["@babel/plugin-syntax-async-generators"]
}
```
### Via CLI
```sh
babel --plugins @babel/syntax-async-generators script.js
babel --plugins @babel/plugin-syntax-async-generators script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/syntax-async-generators"]
plugins: ["@babel/plugin-syntax-async-generators"]
});
```

View File

@ -16,20 +16,20 @@ npm install --save-dev @babel/plugin-syntax-class-properties
```json
{
"plugins": ["@babel/syntax-class-properties"]
"plugins": ["@babel/plugin-syntax-class-properties"]
}
```
### Via CLI
```sh
babel --plugins @babel/syntax-class-properties script.js
babel --plugins @babel/plugin-syntax-class-properties script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/syntax-class-properties"]
plugins: ["@babel/plugin-syntax-class-properties"]
});
```

View File

@ -16,20 +16,20 @@ npm install --save-dev @babel/plugin-syntax-decorators
```json
{
"plugins": ["@babel/syntax-decorators"]
"plugins": ["@babel/plugin-syntax-decorators"]
}
```
### Via CLI
```sh
babel --plugins @babel/syntax-decorators script.js
babel --plugins @babel/plugin-syntax-decorators script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/syntax-decorators"]
plugins: ["@babel/plugin-syntax-decorators"]
});
```

View File

@ -16,20 +16,20 @@ npm install --save-dev @babel/plugin-syntax-do-expressions
```json
{
"plugins": ["@babel/syntax-do-expressions"]
"plugins": ["@babel/plugin-syntax-do-expressions"]
}
```
### Via CLI
```sh
babel --plugins @babel/syntax-do-expressions script.js
babel --plugins @babel/plugin-syntax-do-expressions script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/syntax-do-expressions"]
plugins: ["@babel/plugin-syntax-do-expressions"]
});
```

View File

@ -16,20 +16,20 @@ npm install --save-dev @babel/plugin-syntax-dynamic-import
```json
{
"plugins": ["@babel/syntax-dynamic-import"]
"plugins": ["@babel/plugin-syntax-dynamic-import"]
}
```
### Via CLI
```sh
babel --plugins @babel/syntax-dynamic-import script.js
babel --plugins @babel/plugin-syntax-dynamic-import script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/syntax-dynamic-import"]
plugins: ["@babel/plugin-syntax-dynamic-import"]
});
```

View File

@ -16,20 +16,20 @@ npm install --save-dev @babel/plugin-syntax-export-extensions
```json
{
"plugins": ["@babel/syntax-export-extensions"]
"plugins": ["@babel/plugin-syntax-export-extensions"]
}
```
### Via CLI
```sh
babel --plugins @babel/syntax-export-extensions script.js
babel --plugins @babel/plugin-syntax-export-extensions script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/syntax-export-extensions"]
plugins: ["@babel/plugin-syntax-export-extensions"]
});
```

View File

@ -16,20 +16,20 @@ npm install --save-dev @babel/plugin-syntax-flow
```json
{
"plugins": ["@babel/syntax-flow"]
"plugins": ["@babel/plugin-syntax-flow"]
}
```
### Via CLI
```sh
babel --plugins @babel/syntax-flow script.js
babel --plugins @babel/plugin-syntax-flow script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/syntax-flow"]
plugins: ["@babel/plugin-syntax-flow"]
});
```

View File

@ -16,20 +16,20 @@ npm install --save-dev @babel/plugin-syntax-function-bind
```json
{
"plugins": ["@babel/syntax-function-bind"]
"plugins": ["@babel/plugin-syntax-function-bind"]
}
```
### Via CLI
```sh
babel --plugins @babel/syntax-function-bind script.js
babel --plugins @babel/plugin-syntax-function-bind script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/syntax-function-bind"]
plugins: ["@babel/plugin-syntax-function-bind"]
});
```

View File

@ -16,20 +16,20 @@ npm install --save-dev @babel/plugin-syntax-function-sent
```json
{
"plugins": ["@babel/syntax-function-sent"]
"plugins": ["@babel/plugin-syntax-function-sent"]
}
```
### Via CLI
```sh
babel --plugins @babel/syntax-function-sent script.js
babel --plugins @babel/plugin-syntax-function-sent script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/syntax-function-sent"]
plugins: ["@babel/plugin-syntax-function-sent"]
});
```

View File

@ -16,20 +16,20 @@ npm install --save-dev @babel/plugin-syntax-jsx
```json
{
"plugins": ["@babel/syntax-jsx"]
"plugins": ["@babel/plugin-syntax-jsx"]
}
```
### Via CLI
```sh
babel --plugins @babel/syntax-jsx script.js
babel --plugins @babel/plugin-syntax-jsx script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/syntax-jsx"]
plugins: ["@babel/plugin-syntax-jsx"]
});
```

View File

@ -16,20 +16,20 @@ npm install --save-dev @babel/plugin-syntax-nullish-coalescing-operator
```json
{
"plugins": ["@babel/syntax-nullish-coalescing-operator"]
"plugins": ["@babel/plugin-syntax-nullish-coalescing-operator"]
}
```
### Via CLI
```sh
babel --plugins @babel/syntax-nullish-coalescing-operator script.js
babel --plugins @babel/plugin-syntax-nullish-coalescing-operator script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/syntax-nullish-coalescing-operator"]
plugins: ["@babel/plugin-syntax-nullish-coalescing-operator"]
});
```

View File

@ -17,20 +17,20 @@ npm install --save-dev @babel/plugin-syntax-numeric-separator
```json
{
"plugins": ["@babel/syntax-numeric-separator"]
"plugins": ["@babel/plugin-syntax-numeric-separator"]
}
```
### Via CLI
```sh
babel --plugins @babel/syntax-numeric-separator script.js
babel --plugins @babel/plugin-syntax-numeric-separator script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/syntax-numeric-separator"]
plugins: ["@babel/plugin-syntax-numeric-separator"]
});
```

View File

@ -16,20 +16,20 @@ npm install --save-dev @babel/plugin-syntax-object-rest-spread
```json
{
"plugins": ["@babel/syntax-object-rest-spread"]
"plugins": ["@babel/plugin-syntax-object-rest-spread"]
}
```
### Via CLI
```sh
babel --plugins @babel/syntax-object-rest-spread script.js
babel --plugins @babel/plugin-syntax-object-rest-spread script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/syntax-object-rest-spread"]
plugins: ["@babel/plugin-syntax-object-rest-spread"]
});
```

View File

@ -29,21 +29,21 @@ npm install --save-dev @babel/plugin-syntax-optional-catch-binding
```json
{
"plugins": ["@babel/syntax-optional-catch-binding"]
"plugins": ["@babel/plugin-syntax-optional-catch-binding"]
}
```
### Via CLI
```sh
babel --plugins @babel/syntax-optional-catch-binding script.js
babel --plugins @babel/plugin-syntax-optional-catch-binding script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/syntax-optional-catch-binding"]
plugins: ["@babel/plugin-syntax-optional-catch-binding"]
});
```

View File

@ -16,20 +16,20 @@ npm install --save-dev @babel/plugin-syntax-optional-chaining
```json
{
"plugins": ["@babel/syntax-optional-chaining"]
"plugins": ["@babel/plugin-syntax-optional-chaining"]
}
```
### Via CLI
```sh
babel --plugins @babel/syntax-optional-chaining script.js
babel --plugins @babel/plugin-syntax-optional-chaining script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/syntax-optional-chaining"]
plugins: ["@babel/plugin-syntax-optional-chaining"]
});
```

View File

@ -16,20 +16,20 @@ $ npm install @babel/plugin-syntax-pipeline-operator
```json
{
"plugins": ["@babel/syntax-pipeline-operator"]
"plugins": ["@babel/plugin-syntax-pipeline-operator"]
}
```
### Via CLI
```sh
$ babel --plugins @babel/syntax-pipeline-operator script.js
$ babel --plugins @babel/plugin-syntax-pipeline-operator script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/syntax-pipeline-operator"]
plugins: ["@babel/plugin-syntax-pipeline-operator"]
});
```

View File

@ -23,20 +23,20 @@ npm install --save-dev @babel/plugin-syntax-throw-expressions
```json
{
"plugins": ["@babel/syntax-throw-expressions"]
"plugins": ["@babel/plugin-syntax-throw-expressions"]
}
```
### Via CLI
```sh
babel --plugins @babel/syntax-throw-expressions script.js
babel --plugins @babel/plugin-syntax-throw-expressions script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/syntax-throw-expressions"]
plugins: ["@babel/plugin-syntax-throw-expressions"]
});
```

View File

@ -14,20 +14,20 @@ npm install --save-dev @babel/plugin-syntax-typescript
```json
{
"plugins": ["@babel/syntax-typescript"]
"plugins": ["@babel/plugin-syntax-typescript"]
}
```
### Via CLI
```sh
babel --plugins @babel/syntax-typescript script.js
babel --plugins @babel/plugin-syntax-typescript script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/syntax-typescript"]
plugins: ["@babel/plugin-syntax-typescript"]
});
```

View File

@ -67,7 +67,7 @@ Without options:
```json
{
"plugins": ["@babel/transform-arrow-functions"]
"plugins": ["@babel/plugin-transform-arrow-functions"]
}
```
@ -76,7 +76,7 @@ With options:
```json
{
"plugins": [
["@babel/transform-arrow-functions", { "spec": true }]
["@babel/plugin-transform-arrow-functions", { "spec": true }]
]
}
```
@ -84,14 +84,14 @@ With options:
### Via CLI
```sh
babel --plugins @babel/transform-arrow-functions script.js
babel --plugins @babel/plugin-transform-arrow-functions script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-arrow-functions"]
plugins: ["@babel/plugin-transform-arrow-functions"]
});
```

View File

@ -53,7 +53,7 @@ Without options:
```json
{
"plugins": ["@babel/transform-async-to-generator"]
"plugins": ["@babel/plugin-transform-async-to-generator"]
}
```
@ -62,7 +62,7 @@ With options:
```json
{
"plugins": [
["@babel/transform-async-to-generator", {
["@babel/plugin-transform-async-to-generator", {
"module": "bluebird",
"method": "coroutine"
}]
@ -73,14 +73,14 @@ With options:
### Via CLI
```sh
babel --plugins @babel/transform-async-to-generator script.js
babel --plugins @babel/plugin-transform-async-to-generator script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-async-to-generator"]
plugins: ["@babel/plugin-transform-async-to-generator"]
});
```

View File

@ -42,20 +42,20 @@ npm install --save-dev @babel/plugin-transform-block-scoped-functions
```json
{
"plugins": ["@babel/transform-block-scoped-functions"]
"plugins": ["@babel/plugin-transform-block-scoped-functions"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-block-scoped-functions script.js
babel --plugins @babel/plugin-transform-block-scoped-functions script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-block-scoped-functions"]
plugins: ["@babel/plugin-transform-block-scoped-functions"]
});
```

View File

@ -40,7 +40,7 @@ Without options:
```json
{
"plugins": ["@babel/transform-block-scoping"]
"plugins": ["@babel/plugin-transform-block-scoping"]
}
```
@ -49,7 +49,7 @@ With options:
```json
{
"plugins": [
["@babel/transform-block-scoping", {
["@babel/plugin-transform-block-scoping", {
"throwIfClosureRequired": true
}]
]
@ -59,14 +59,14 @@ With options:
### Via CLI
```sh
babel --plugins @babel/transform-block-scoping script.js
babel --plugins @babel/plugin-transform-block-scoping script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-block-scoping"]
plugins: ["@babel/plugin-transform-block-scoping"]
});
```

View File

@ -6,7 +6,7 @@
Built-in classes such as `Date`, `Array`, `DOM` etc cannot be properly subclassed
due to limitations in ES5 (for the [classes](http://babeljs.io/docs/plugins/transform-classes) plugin).
You can try to use [babel-plugin-transform-builtin-extend](https://github.com/loganfsmyth/babel-plugin-transform-builtin-extend) based on `Object.setPrototypeOf` and `Reflect.construct`, but it also has some limitations.
You can try to use [@babel/plugin-transform-builtin-extend](https://github.com/loganfsmyth/babel-plugin-transform-builtin-extend) based on `Object.setPrototypeOf` and `Reflect.construct`, but it also has some limitations.
## Examples
@ -59,13 +59,13 @@ npm install --save-dev @babel/plugin-transform-classes
```js
// without options
{
"plugins": ["@babel/transform-classes"]
"plugins": ["@babel/plugin-transform-classes"]
}
// with options
{
"plugins": [
["@babel/transform-classes", {
["@babel/plugin-transform-classes", {
"loose": true
}]
]
@ -75,14 +75,14 @@ npm install --save-dev @babel/plugin-transform-classes
### Via CLI
```sh
babel --plugins @babel/transform-classes script.js
babel --plugins @babel/plugin-transform-classes script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-classes"]
plugins: ["@babel/plugin-transform-classes"]
});
```

View File

@ -61,7 +61,7 @@ Without options:
```json
{
"plugins": ["@babel/transform-computed-properties"]
"plugins": ["@babel/plugin-transform-computed-properties"]
}
```
@ -70,7 +70,7 @@ With options:
```json
{
"plugins": [
["@babel/transform-computed-properties", {
["@babel/plugin-transform-computed-properties", {
"loose": true
}]
]
@ -80,14 +80,14 @@ With options:
### Via CLI
```sh
babel --plugins @babel/transform-computed-properties script.js
babel --plugins @babel/plugin-transform-computed-properties script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-computed-properties"]
plugins: ["@babel/plugin-transform-computed-properties"]
});
```

View File

@ -34,20 +34,20 @@ npm install --save-dev @babel/plugin-transform-destructuring
```json
{
"plugins": ["@babel/transform-destructuring"]
"plugins": ["@babel/plugin-transform-destructuring"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-destructuring script.js
babel --plugins @babel/plugin-transform-destructuring script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-destructuring"]
plugins: ["@babel/plugin-transform-destructuring"]
});
```

View File

@ -2,7 +2,7 @@
> Compile objects with duplicate keys to valid strict ES5.
This plugin actually converts duplicate keys in objects to be computed properties, which then must be handled by the [transform-computed-properties](http://babeljs.io/docs/plugins/transform-computed-properties) plugin. The final result won't contain any object literals with duplicate keys.
This plugin actually converts duplicate keys in objects to be computed properties, which then must be handled by the [@babel/plugin-transform-computed-properties](http://babeljs.io/docs/plugins/transform-computed-properties) plugin. The final result won't contain any object literals with duplicate keys.
## Example
@ -42,20 +42,20 @@ npm install --save-dev @babel/plugin-transform-duplicate-keys
```json
{
"plugins": ["@babel/transform-duplicate-keys"]
"plugins": ["@babel/plugin-transform-duplicate-keys"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-duplicate-keys script.js
babel --plugins @babel/plugin-transform-duplicate-keys script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-duplicate-keys"]
plugins: ["@babel/plugin-transform-duplicate-keys"]
});
```

View File

@ -30,20 +30,20 @@ npm install --save-dev @babel/plugin-transform-eval
```json
{
"plugins": ["@babel/transform-eval"]
"plugins": ["@babel/plugin-transform-eval"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-eval script.js
babel --plugins @babel/plugin-transform-eval script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-eval"]
plugins: ["@babel/plugin-transform-eval"]
});
```

View File

@ -39,21 +39,21 @@ npm install --save-dev @babel/plugin-transform-exponentiation-operator
```json
{
"plugins": ["@babel/transform-exponentiation-operator"]
"plugins": ["@babel/plugin-transform-exponentiation-operator"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-exponentiation-operator script.js
babel --plugins @babel/plugin-transform-exponentiation-operator script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-exponentiation-operator"]
plugins: ["@babel/plugin-transform-exponentiation-operator"]
});
```

View File

@ -52,20 +52,20 @@ npm install --save-dev @babel/plugin-transform-flow-comments
```json
{
"plugins": ["@babel/transform-flow-comments"]
"plugins": ["@babel/plugin-transform-flow-comments"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-flow-comments script.js
babel --plugins @babel/plugin-transform-flow-comments script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-flow-comments"]
plugins: ["@babel/plugin-transform-flow-comments"]
});
```

View File

@ -30,21 +30,21 @@ npm install --save-dev @babel/plugin-transform-flow-strip-types
```json
{
"plugins": ["@babel/transform-flow-strip-types"]
"plugins": ["@babel/plugin-transform-flow-strip-types"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-flow-strip-types script.js
babel --plugins @babel/plugin-transform-flow-strip-types script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-flow-strip-types"]
plugins: ["@babel/plugin-transform-flow-strip-types"]
});
```

View File

@ -53,7 +53,7 @@ Without options:
```js
{
"plugins": ["@babel/transform-for-of"]
"plugins": ["@babel/plugin-transform-for-of"]
}
```
@ -62,7 +62,7 @@ With options:
```json
{
"plugins": [
["@babel/transform-for-of", {
["@babel/plugin-transform-for-of", {
"loose": true
}]
]
@ -72,14 +72,14 @@ With options:
### Via CLI
```sh
babel --plugins @babel/transform-for-of script.js
babel --plugins @babel/plugin-transform-for-of script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-for-of"]
plugins: ["@babel/plugin-transform-for-of"]
});
```

View File

@ -32,20 +32,20 @@ npm install --save-dev @babel/plugin-transform-function-name
```json
{
"plugins": ["@babel/transform-function-name"]
"plugins": ["@babel/plugin-transform-function-name"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-function-name script.js
babel --plugins @babel/plugin-transform-function-name script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-function-name"]
plugins: ["@babel/plugin-transform-function-name"]
});
```

View File

@ -14,20 +14,20 @@ npm install --save-dev @babel/plugin-transform-instanceof
```json
{
"plugins": ["@babel/transform-instanceof"]
"plugins": ["@babel/plugin-transform-instanceof"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-instanceof script.js
babel --plugins @babel/plugin-transform-instanceof script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-instanceof"]
plugins: ["@babel/plugin-transform-instanceof"]
});
```

View File

@ -38,20 +38,20 @@ npm install --save-dev @babel/plugin-transform-jscript
```json
{
"plugins": ["@babel/transform-jscript"]
"plugins": ["@babel/plugin-transform-jscript"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-jscript script.js
babel --plugins @babel/plugin-transform-jscript script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-jscript"]
plugins: ["@babel/plugin-transform-jscript"]
});
```

View File

@ -34,20 +34,20 @@ npm install --save-dev @babel/plugin-transform-literals
```json
{
"plugins": ["@babel/transform-literals"]
"plugins": ["@babel/plugin-transform-literals"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-literals script.js
babel --plugins @babel/plugin-transform-literals script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-literals"]
plugins: ["@babel/plugin-transform-literals"]
});
```

View File

@ -30,20 +30,20 @@ npm install --save-dev @babel/plugin-transform-member-expression-literals
```json
{
"plugins": ["@babel/transform-member-expression-literals"]
"plugins": ["@babel/plugin-transform-member-expression-literals"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-member-expression-literals script.js
babel --plugins @babel/plugin-transform-member-expression-literals script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-member-expression-literals"]
plugins: ["@babel/plugin-transform-member-expression-literals"]
});
```

View File

@ -38,24 +38,24 @@ npm install --save-dev @babel/plugin-transform-modules-amd
```json
{
"plugins": ["@babel/transform-modules-amd"]
"plugins": ["@babel/plugin-transform-modules-amd"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-modules-amd script.js
babel --plugins @babel/plugin-transform-modules-amd script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-modules-amd"]
plugins: ["@babel/plugin-transform-modules-amd"]
});
```
### Options
See options for `babel-plugin-transform-commonjs`.
See options for `@babel/plugin-transform-modules-commonjs`.

View File

@ -35,13 +35,13 @@ npm install --save-dev @babel/plugin-transform-modules-commonjs
```js
// without options
{
"plugins": ["@babel/transform-modules-commonjs"]
"plugins": ["@babel/plugin-transform-modules-commonjs"]
}
// with options
{
"plugins": [
["@babel/transform-modules-commonjs", {
["@babel/plugin-transform-modules-commonjs", {
"allowTopLevelThis": true
}]
]
@ -51,14 +51,14 @@ npm install --save-dev @babel/plugin-transform-modules-commonjs
### Via CLI
```sh
babel --plugins @babel/transform-modules-commonjs script.js
babel --plugins @babel/plugin-transform-modules-commonjs script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-modules-commonjs"]
plugins: ["@babel/plugin-transform-modules-commonjs"]
});
```
@ -82,7 +82,7 @@ Object.defineProperty(exports, "__esModule", {
});
```
In environments that don't support this you can enable loose mode on `babel-plugin-transform-modules-commonjs`
In environments that don't support this you can enable loose mode on `@babel/plugin-transform-modules-commonjs`
and instead of using `Object.defineProperty` an assignment will be used instead.
```javascript

View File

@ -23,7 +23,7 @@ System.register([], function (_export, _context) {
});
```
For dynamic import support (`import('./lazy.js').then(m => ...)`), enable the [syntax-dynamic-import](https://babeljs.io/docs/plugins/syntax-dynamic-import/) plugin before this one.
For dynamic import support (`import('./lazy.js').then(m => ...)`), enable the [@babel/plugin-syntax-dynamic-import](https://babeljs.io/docs/plugins/syntax-dynamic-import/) plugin before this one.
## Installation
@ -41,7 +41,7 @@ Without options:
```json
{
"plugins": ["@babel/transform-modules-systemjs"]
"plugins": ["@babel/plugin-transform-modules-systemjs"]
}
```
@ -50,7 +50,7 @@ With options:
```json
{
"plugins": [
["@babel/transform-modules-systemjs", {
["@babel/plugin-transform-modules-systemjs", {
// outputs SystemJS.register(...)
"systemGlobal": "SystemJS"
}]
@ -61,13 +61,13 @@ With options:
### Via CLI
```sh
babel --plugins @babel/transform-modules-systemjs script.js
babel --plugins @babel/plugin-transform-modules-systemjs script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-modules-systemjs"]
plugins: ["@babel/plugin-transform-modules-systemjs"]
});
```

View File

@ -50,7 +50,7 @@ npm install --save-dev @babel/plugin-transform-modules-umd
```json
{
"plugins": ["@babel/transform-modules-umd"]
"plugins": ["@babel/plugin-transform-modules-umd"]
}
```
@ -61,7 +61,7 @@ as `global.Promise` rather than `global.es6Promise`. This can be accommodated by
```json
{
"plugins": [
["@babel/transform-modules-umd", {
["@babel/plugin-transform-modules-umd", {
"globals": {
"es6-promise": "Promise"
}
@ -177,8 +177,8 @@ Finally, with the plugin options set to:
```json
{
"plugins": [
"external-helpers",
["@babel/transform-modules-umd", {
"@babel/plugin-external-helpers",
["@babel/plugin-transform-modules-umd", {
"globals": {
"my/custom/module/name": "My.Custom.Module.Name"
},
@ -202,13 +202,13 @@ global.My.Custom.Module.Name = mod.exports;
### Via CLI
```sh
babel --plugins @babel/transform-modules-umd script.js
babel --plugins @babel/plugin-transform-modules-umd script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-modules-umd"]
plugins: ["@babel/plugin-transform-modules-umd"]
});
```

View File

@ -85,20 +85,20 @@ npm install --save-dev @babel/plugin-transform-new-target
```json
{
"plugins": ["@babel/transform-new-target"]
"plugins": ["@babel/plugin-transform-new-target"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-new-target script.js
babel --plugins @babel/plugin-transform-new-target script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-new-target"]
plugins: ["@babel/plugin-transform-new-target"]
});
```

View File

@ -41,20 +41,20 @@ npm install --save-dev @babel/plugin-transform-object-assign
```json
{
"plugins": ["@babel/transform-object-assign"]
"plugins": ["@babel/plugin-transform-object-assign"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-object-assign script.js
babel --plugins @babel/plugin-transform-object-assign script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-object-assign"]
plugins: ["@babel/plugin-transform-object-assign"]
});
```

View File

@ -34,20 +34,20 @@ npm install --save-dev @babel/plugin-transform-object-set-prototype-of-to-assign
```json
{
"plugins": ["@babel/transform-object-set-prototype-of-to-assign"]
"plugins": ["@babel/plugin-transform-object-set-prototype-of-to-assign"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-object-set-prototype-of-to-assign script.js
babel --plugins @babel/plugin-transform-object-set-prototype-of-to-assign script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-object-set-prototype-of-to-assign"]
plugins: ["@babel/plugin-transform-object-set-prototype-of-to-assign"]
});
```

View File

@ -54,20 +54,20 @@ npm install --save-dev @babel/plugin-transform-object-super
```json
{
"plugins": ["@babel/transform-object-super"]
"plugins": ["@babel/plugin-transform-object-super"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-object-super script.js
babel --plugins @babel/plugin-transform-object-super script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-object-super"]
plugins: ["@babel/plugin-transform-object-super"]
});
```

View File

@ -45,7 +45,7 @@ npm install --save-dev @babel/plugin-transform-parameters
Default parameters desugar into `let` declarations to retain proper semantics. If this is
not supported in your environment then you'll need the
[transform-block-scoping](http://babeljs.io/docs/plugins/transform-block-scoping) plugin.
[@babel/plugin-transform-block-scoping](http://babeljs.io/docs/plugins/transform-block-scoping) plugin.
## Usage
@ -55,21 +55,21 @@ not supported in your environment then you'll need the
```json
{
"plugins": ["@babel/transform-parameters"]
"plugins": ["@babel/plugin-transform-parameters"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-parameters script.js
babel --plugins @babel/plugin-transform-parameters script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-parameters"]
plugins: ["@babel/plugin-transform-parameters"]
});
```

View File

@ -34,20 +34,20 @@ npm install --save-dev @babel/plugin-transform-property-literals
```json
{
"plugins": ["@babel/transform-property-literals"]
"plugins": ["@babel/plugin-transform-property-literals"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-property-literals script.js
babel --plugins @babel/plugin-transform-property-literals script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-property-literals"]
plugins: ["@babel/plugin-transform-property-literals"]
});
```

View File

@ -42,20 +42,20 @@ npm install --save-dev @babel/plugin-transform-property-mutators
```json
{
"plugins": ["@babel/transform-property-mutators"]
"plugins": ["@babel/plugin-transform-property-mutators"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-property-mutators script.js
babel --plugins @babel/plugin-transform-property-mutators script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-property-mutators"]
plugins: ["@babel/plugin-transform-property-mutators"]
});
```

View File

@ -57,20 +57,20 @@ npm install --save-dev @babel/plugin-transform-proto-to-assign
```json
{
"plugins": ["@babel/transform-proto-to-assign"]
"plugins": ["@babel/plugin-transform-proto-to-assign"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-proto-to-assign script.js
babel --plugins @babel/plugin-transform-proto-to-assign script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-proto-to-assign"]
plugins: ["@babel/plugin-transform-proto-to-assign"]
});
```

View File

@ -62,7 +62,7 @@ npm install --save-dev @babel/plugin-transform-react-constant-elements
```json
{
"plugins": ["@babel/transform-react-constant-elements"]
"plugins": ["@babel/plugin-transform-react-constant-elements"]
}
```
@ -80,7 +80,7 @@ This will skip the `Mutable Properties` deopt.
```json
{
"plugins": [
["@babel/transform-react-constant-elements", {"allowMutablePropsOnTags": ["FormattedMessage"]}],
["@babel/plugin-transform-react-constant-elements", {"allowMutablePropsOnTags": ["FormattedMessage"]}],
]
}
@ -89,14 +89,14 @@ This will skip the `Mutable Properties` deopt.
### Via CLI
```sh
babel --plugins @babel/transform-react-constant-elements script.js
babel --plugins @babel/plugin-transform-react-constant-elements script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-react-constant-elements"]
plugins: ["@babel/plugin-transform-react-constant-elements"]
});
```

View File

@ -36,20 +36,20 @@ npm install --save-dev @babel/plugin-transform-react-display-name
```json
{
"plugins": ["@babel/transform-react-display-name"]
"plugins": ["@babel/plugin-transform-react-display-name"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-react-display-name script.js
babel --plugins @babel/plugin-transform-react-display-name script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-react-display-name"]
plugins: ["@babel/plugin-transform-react-display-name"]
});
```

View File

@ -4,9 +4,9 @@
## Note
When used alongside `transform-runtime`, polyfills (by default including `Symbol`) are specifically scoped to not pollute the global scope. This breaks usage with React, as it won't have access to that polyfill and will cause your application to fail in legacy browsers.
When used alongside `@babel/plugin-transform-runtime`, polyfills (by default including `Symbol`) are specifically scoped to not pollute the global scope. This breaks usage with React, as it won't have access to that polyfill and will cause your application to fail in legacy browsers.
Even if `['transform-runtime', { helpers: true, polyfill: false }]` is specified, it might still break, since `helpers` come precompiled.
Even if `['@babel/plugin-transform-runtime', { helpers: true, polyfill: false }]` is specified, it might still break, since `helpers` come precompiled.
In this case, we recommend importing/requiring `@babel/polyfill` in the entry point of your application and using `@babel/preset-env` with the `useBuiltIns` option to only include the polyfills your targets need. Alternatively, you can also import/require `core-js/modules/es6.symbol` by itself.
@ -59,21 +59,21 @@ npm install --save-dev @babel/plugin-transform-react-inline-elements
```json
{
"plugins": ["@babel/transform-react-inline-elements"]
"plugins": ["@babel/plugin-transform-react-inline-elements"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-react-inline-elements script.js
babel --plugins @babel/plugin-transform-react-inline-elements script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-react-inline-elements"]
plugins: ["@babel/plugin-transform-react-inline-elements"]
});
```

View File

@ -36,20 +36,20 @@ npm install --save-dev @babel/plugin-transform-react-jsx-compat
```json
{
"plugins": ["@babel/transform-react-jsx-compat"]
"plugins": ["@babel/plugin-transform-react-jsx-compat"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-react-jsx-compat script.js
babel --plugins @babel/plugin-transform-react-jsx-compat script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-react-jsx-compat"]
plugins: ["@babel/plugin-transform-react-jsx-compat"]
});
```

View File

@ -30,20 +30,20 @@ npm install --save-dev @babel/plugin-transform-react-jsx-self
```json
{
"plugins": ["@babel/transform-react-jsx-self"]
"plugins": ["@babel/plugin-transform-react-jsx-self"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-react-jsx-self script.js
babel --plugins @babel/plugin-transform-react-jsx-self script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-react-jsx-self"]
plugins: ["@babel/plugin-transform-react-jsx-self"]
});
```

View File

@ -30,20 +30,20 @@ npm install --save-dev @babel/plugin-transform-react-jsx-source
```json
{
"plugins": ["@babel/transform-react-jsx-source"]
"plugins": ["@babel/plugin-transform-react-jsx-source"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-react-jsx-source script.js
babel --plugins @babel/plugin-transform-react-jsx-source script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-react-jsx-source"]
plugins: ["@babel/plugin-transform-react-jsx-source"]
});
```

View File

@ -132,7 +132,7 @@ Without options:
```json
{
"plugins": ["@babel/transform-react-jsx"]
"plugins": ["@babel/plugin-transform-react-jsx"]
}
```
@ -141,7 +141,7 @@ With options:
```json
{
"plugins": [
["@babel/transform-react-jsx", {
["@babel/plugin-transform-react-jsx", {
"pragma": "dom", // default pragma is React.createElement
"pragmaFrag": "DomFrag", // default is React.Fragment
"throwIfNamespace": false // defaults to true
@ -153,14 +153,14 @@ With options:
### Via CLI
```sh
babel --plugins @babel/transform-react-jsx script.js
babel --plugins @babel/plugin-transform-react-jsx script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-react-jsx"]
plugins: ["@babel/plugin-transform-react-jsx"]
});
```

View File

@ -48,7 +48,7 @@ Without options:
```json
{
"plugins": ["@babel/transform-regenerator"]
"plugins": ["@babel/plugin-transform-regenerator"]
}
```
@ -63,7 +63,7 @@ With options:
```json
{
"plugins": [
["@babel/transform-regenerator", {
["@babel/plugin-transform-regenerator", {
"asyncGenerators": false,
"generators": false,
"async": false
@ -75,13 +75,13 @@ With options:
### Via CLI
```sh
babel --plugins @babel/transform-regenerator script.js
babel --plugins @babel/plugin-transform-regenerator script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-regenerator"]
plugins: ["@babel/plugin-transform-regenerator"]
});
```

View File

@ -8,7 +8,7 @@ NOTE: Instance methods such as `"foobar".includes("foo")` will not work since th
Babel uses very small helpers for common functions such as `_extend`. By default this will be added to every file that requires it. This duplication is sometimes unnecessary, especially when your application is spread out over multiple files.
This is where the `transform-runtime` plugin comes in: all of the helpers will reference the module `@babel/runtime` to avoid duplication across your compiled output. The runtime will be compiled into your build.
This is where the `@babel/plugin-transform-runtime` plugin comes in: all of the helpers will reference the module `@babel/runtime` to avoid duplication across your compiled output. The runtime will be compiled into your build.
Another purpose of this transformer is to create a sandboxed environment for your code. If you use [@babel/polyfill](http://babeljs.io/docs/usage/polyfill/) and the built-ins it provides such as `Promise`, `Set` and `Map`, those will pollute the global scope. While this might be ok for an app or a command line tool, it becomes a problem if your code is a library which you intend to publish for others to use or if you can't exactly control the environment in which your code will run.
@ -44,7 +44,7 @@ Without options:
```json
{
"plugins": ["@babel/transform-runtime"]
"plugins": ["@babel/plugin-transform-runtime"]
}
```
@ -53,7 +53,7 @@ With options:
```json
{
"plugins": [
["@babel/transform-runtime", {
["@babel/plugin-transform-runtime", {
"helpers": false,
"polyfill": false,
"regenerator": true,
@ -66,14 +66,14 @@ With options:
### Via CLI
```sh
babel --plugins @babel/transform-runtime script.js
babel --plugins @babel/plugin-transform-runtime script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-runtime"]
plugins: ["@babel/plugin-transform-runtime"]
});
```
@ -171,7 +171,7 @@ exports.default = function (left, right) {
`boolean`, defaults to `false`.
When enabled, the transform will use helpers that do not get run through
`transform-modules-commonjs`. This allows for smaller builds in module
`@babel/plugin-transform-modules-commonjs`. This allows for smaller builds in module
systems like webpack, since it doesn't need to preserve commonjs semantics.
For example, here is the `classCallCheck` helper with `useESModules` disabled:

View File

@ -50,20 +50,20 @@ npm install --save-dev @babel/plugin-transform-shorthand-properties
```json
{
"plugins": ["@babel/transform-shorthand-properties"]
"plugins": ["@babel/plugin-transform-shorthand-properties"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-shorthand-properties script.js
babel --plugins @babel/plugin-transform-shorthand-properties script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-shorthand-properties"]
plugins: ["@babel/plugin-transform-shorthand-properties"]
});
```

View File

@ -34,7 +34,7 @@ Without options:
```json
{
"plugins": ["@babel/transform-spread"]
"plugins": ["@babel/plugin-transform-spread"]
}
```
@ -43,7 +43,7 @@ With options:
```json
{
"plugins": [
["@babel/transform-spread", {
["@babel/plugin-transform-spread", {
"loose": true
}]
]
@ -53,14 +53,14 @@ With options:
### Via CLI
```sh
babel --plugins @babel/transform-spread script.js
babel --plugins @babel/plugin-transform-spread script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-spread"]
plugins: ["@babel/plugin-transform-spread"]
});
```

View File

@ -30,20 +30,20 @@ npm install --save-dev @babel/plugin-transform-sticky-regex
```json
{
"plugins": ["@babel/transform-sticky-regex"]
"plugins": ["@babel/plugin-transform-sticky-regex"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-sticky-regex script.js
babel --plugins @babel/plugin-transform-sticky-regex script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-sticky-regex"]
plugins: ["@babel/plugin-transform-sticky-regex"]
});
```

View File

@ -37,7 +37,7 @@ npm install --save-dev @babel/plugin-transform-strict-mode
```json
{
"plugins": ["@babel/transform-strict-mode"]
"plugins": ["@babel/plugin-transform-strict-mode"]
}
```
@ -45,13 +45,13 @@ npm install --save-dev @babel/plugin-transform-strict-mode
### Via CLI
```sh
babel --plugins @babel/transform-strict-mode script.js
babel --plugins @babel/plugin-transform-strict-mode script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-strict-mode"]
plugins: ["@babel/plugin-transform-strict-mode"]
});
```

View File

@ -32,7 +32,7 @@ Without options:
```json
{
"plugins": ["@babel/transform-template-literals"]
"plugins": ["@babel/plugin-transform-template-literals"]
}
```
@ -41,7 +41,7 @@ With options:
```json
{
"plugins": [
["@babel/transform-template-literals", {
["@babel/plugin-transform-template-literals", {
"loose": true
}]
]
@ -51,14 +51,14 @@ With options:
### Via CLI
```sh
babel --plugins @babel/transform-template-literals script.js
babel --plugins @babel/plugin-transform-template-literals script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-template-literals"]
plugins: ["@babel/plugin-transform-template-literals"]
});
```

View File

@ -34,20 +34,20 @@ npm install --save-dev @babel/plugin-transform-typeof-symbol
```json
{
"plugins": ["@babel/transform-typeof-symbol"]
"plugins": ["@babel/plugin-transform-typeof-symbol"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-typeof-symbol script.js
babel --plugins @babel/plugin-transform-typeof-symbol script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-typeof-symbol"]
plugins: ["@babel/plugin-transform-typeof-symbol"]
});
```

View File

@ -35,20 +35,20 @@ npm install --save-dev @babel/plugin-transform-typescript
```json
{
"plugins": ["@babel/transform-typescript"]
"plugins": ["@babel/plugin-transform-typescript"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-typescript script.js
babel --plugins @babel/plugin-transform-typescript script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-typescript"]
plugins: ["@babel/plugin-transform-typescript"]
});
```

View File

@ -32,20 +32,20 @@ npm install --save-dev @babel/plugin-transform-unicode-regex
```json
{
"plugins": ["@babel/transform-unicode-regex"]
"plugins": ["@babel/plugin-transform-unicode-regex"]
}
```
### Via CLI
```sh
babel --plugins @babel/transform-unicode-regex script.js
babel --plugins @babel/plugin-transform-unicode-regex script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/transform-unicode-regex"]
plugins: ["@babel/plugin-transform-unicode-regex"]
});
```

View File

@ -16,21 +16,21 @@ npm install --save-dev @babel/preset-es2015
```json
{
"presets": ["@babel/es2015"]
"presets": ["@babel/preset-es2015"]
}
```
### Via CLI
```sh
babel script.js --presets @babel/es2015
babel script.js --presets @babel/preset-es2015
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
presets: ["@babel/es2015"]
presets: ["@babel/preset-es2015"]
});
```

View File

@ -16,20 +16,20 @@ npm install --save-dev @babel/preset-es2016
```json
{
"presets": ["@babel/es2016"]
"presets": ["@babel/preset-es2016"]
}
```
### Via CLI
```sh
babel script.js --presets @babel/es2016
babel script.js --presets @babel/preset-es2016
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
presets: ["@babel/es2016"]
presets: ["@babel/preset-es2016"]
});
```

View File

@ -16,20 +16,20 @@ npm install --save-dev @babel/preset-es2017
```json
{
"presets": ["@babel/es2017"]
"presets": ["@babel/preset-es2017"]
}
```
### Via CLI
```sh
babel script.js --presets @babel/es2017
babel script.js --presets @babel/preset-es2017
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
presets: ["@babel/es2017"]
presets: ["@babel/preset-es2017"]
});
```

View File

@ -4,7 +4,7 @@
This preset includes the following plugins:
- [transform-flow-strip-types](https://babeljs.io/docs/plugins/transform-flow-strip-types/)
- [@babel/plugin-transform-flow-strip-types](https://babeljs.io/docs/plugins/transform-flow-strip-types/)
## Example
@ -34,20 +34,20 @@ npm install --save-dev @babel/preset-flow
```json
{
"presets": ["@babel/flow"]
"presets": ["@babel/preset-flow"]
}
```
### Via CLI
```sh
babel --presets @babel/flow script.js
babel --presets @babel/preset-flow script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
presets: ["@babel/flow"]
presets: ["@babel/preset-flow"]
});
```

View File

@ -4,14 +4,14 @@
This preset always includes the following plugins:
- [syntax-jsx](https://babeljs.io/docs/plugins/syntax-jsx/)
- [transform-react-jsx](https://babeljs.io/docs/plugins/transform-react-jsx/)
- [transform-react-display-name](https://babeljs.io/docs/plugins/transform-react-display-name/)
- [@babel/plugin-syntax-jsx](https://babeljs.io/docs/plugins/syntax-jsx/)
- [@babel/plugin-transform-react-jsx](https://babeljs.io/docs/plugins/transform-react-jsx/)
- [@babel/plugin-transform-react-display-name](https://babeljs.io/docs/plugins/transform-react-display-name/)
And with the `development` option:
- [transform-react-jsx-self](https://babeljs.io/docs/plugins/transform-react-jsx-self/)
- [transform-react-jsx-source](https://babeljs.io/docs/plugins/transform-react-jsx-source/)
- [@babel/plugin-transform-react-jsx-self](https://babeljs.io/docs/plugins/transform-react-jsx-self/)
- [@babel/plugin-transform-react-jsx-source](https://babeljs.io/docs/plugins/transform-react-jsx-source/)
> Note: Flow syntax support is no longer enabled in v7. For that, you will need to add the [Flow preset](https://babeljs.io/docs/plugins/preset-flow/).
@ -33,7 +33,7 @@ Without options:
```json
{
"presets": ["@babel/react"]
"presets": ["@babel/preset-react"]
}
```
@ -42,7 +42,7 @@ With options:
```json
{
"presets": [
["@babel/react", {
["@babel/preset-react", {
"pragma": "dom", // default pragma is React.createElement
"pragmaFrag": "DomFrag", // default is React.Fragment
"throwIfNamespace": false // defaults to true
@ -54,14 +54,14 @@ With options:
### Via CLI
```sh
babel --presets @babel/react script.js
babel --presets @babel/preset-react script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
presets: ["@babel/react"]
presets: ["@babel/preset-react"]
});
```
@ -108,7 +108,7 @@ Though the JSX spec allows this, it is disabled by default since React's JSX doe
```js
module.exports = {
presets: [
["@babel/react", {
["@babel/preset-react", {
development: process.env.BABEL_ENV === "development",
}],
],
@ -121,11 +121,11 @@ module.exports = {
```json
{
"presets": ["@babel/react"],
"presets": ["@babel/preset-react"],
"env": {
"development": {
"presets": [
["@babel/react", { "development": true }]
["@babel/preset-react", { "development": true }]
]
}
}

View File

@ -16,21 +16,21 @@ npm install --save-dev @babel/preset-stage-0
```json
{
"presets": ["@babel/stage-0"]
"presets": ["@babel/preset-stage-0"]
}
```
### Via CLI
```sh
babel script.js --presets @babel/stage-0
babel script.js --presets @babel/preset-stage-0
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
presets: ["@babel/stage-0"]
presets: ["@babel/preset-stage-0"]
});
```

View File

@ -26,21 +26,21 @@ npm install --save-dev @babel/preset-stage-1
```json
{
"presets": ["@babel/stage-1"]
"presets": ["@babel/preset-stage-1"]
}
```
### Via CLI
```sh
babel script.js --presets @babel/stage-1
babel script.js --presets @babel/preset-stage-1
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
presets: ["@babel/stage-1"]
presets: ["@babel/preset-stage-1"]
});
```

View File

@ -26,21 +26,21 @@ npm install --save-dev @babel/preset-stage-2
```json
{
"presets": ["@babel/stage-2"]
"presets": ["@babel/preset-stage-2"]
}
```
### Via CLI
```sh
babel script.js --presets @babel/stage-2
babel script.js --presets @babel/preset-stage-2
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
presets: ["@babel/stage-2"]
presets: ["@babel/preset-stage-2"]
});
```

View File

@ -26,21 +26,21 @@ npm install --save-dev @babel/preset-stage-3
```json
{
"presets": ["@babel/stage-3"]
"presets": ["@babel/preset-stage-3"]
}
```
### Via CLI
```sh
babel script.js --presets @babel/stage-3
babel script.js --presets @babel/preset-stage-3
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
presets: ["@babel/stage-3"]
presets: ["@babel/preset-stage-3"]
});
```

View File

@ -4,9 +4,9 @@
This preset includes the following plugins:
- [transform-typescript](https://babeljs.io/docs/plugins/transform-typescript/)
- [@babel/plugin-transform-typescript](https://babeljs.io/docs/plugins/transform-typescript/)
> You will need to specify `--extensions ".ts"` for `babel-cli`, `babel-node` to handle `.ts` files.
> You will need to specify `--extensions ".ts"` for `@babel/cli` & `@babel/node` cli's to handle `.ts` files.
## Example
@ -36,20 +36,20 @@ npm install --save-dev @babel/preset-typescript
```json
{
"presets": ["@babel/typescript"]
"presets": ["@babel/preset-typescript"]
}
```
### Via CLI
```sh
babel --presets @babel/typescript script.ts
babel --presets @babel/preset-typescript script.ts
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
presets: ["@babel/typescript"]
presets: ["@babel/preset-typescript"]
});
```

View File

@ -79,7 +79,7 @@ to each file still applies, and takes precedence over any options you pass in he
## Environment variables
By default `babel-node` and `@babel/register` will save to a json cache in your
By default `@babel/node` cli and `@babel/register` will save to a json cache in your
temporary directory.
This will heavily improve with the startup and compilation of your files. There

Some files were not shown because too many files have changed in this diff Show More