Refactor move docs (#8108)
* feat: [skip] generate readme script * docs: [skip ci] update READMEs * docs: [skip ci] fix code block type * chore: [skip ci] move generator script
This commit is contained in:
@@ -1,61 +1,19 @@
|
||||
# @babel/plugin-transform-duplicate-keys
|
||||
|
||||
> Compile objects with duplicate keys to valid strict ES5.
|
||||
> 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 [@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.
|
||||
See our website [@babel/plugin-transform-duplicate-keys](https://new.babeljs.io/docs/en/next/babel-plugin-transform-duplicate-keys.html) for more information.
|
||||
|
||||
## Example
|
||||
## Install
|
||||
|
||||
**In**
|
||||
|
||||
```javascript
|
||||
var x = { a: 5, a: 6 };
|
||||
var y = {
|
||||
get a() {},
|
||||
set a(x) {},
|
||||
a: 3
|
||||
};
|
||||
```
|
||||
|
||||
**Out**
|
||||
|
||||
```javascript
|
||||
var x = { a: 5, ["a"]: 6 };
|
||||
var y = {
|
||||
get a() {},
|
||||
set a(x) {},
|
||||
["a"]: 3
|
||||
};
|
||||
```
|
||||
|
||||
## Installation
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/plugin-transform-duplicate-keys
|
||||
npm install --save @babel/plugin-transform-duplicate-keys
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Via `.babelrc` (Recommended)
|
||||
|
||||
**.babelrc**
|
||||
|
||||
```json
|
||||
{
|
||||
"plugins": ["@babel/plugin-transform-duplicate-keys"]
|
||||
}
|
||||
```
|
||||
|
||||
### Via CLI
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
babel --plugins @babel/plugin-transform-duplicate-keys script.js
|
||||
```
|
||||
|
||||
### Via Node API
|
||||
|
||||
```javascript
|
||||
require("@babel/core").transform("code", {
|
||||
plugins: ["@babel/plugin-transform-duplicate-keys"]
|
||||
});
|
||||
yarn add --save @babel/plugin-transform-duplicate-keys
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user