aswi2020vldc-gitlab/templetes/node_modules/babel-plugin-transform-react-jsx-source/README.md @ 9bb1e829
1 |
# babel-plugin-transform-react-jsx-source
|
---|---|
2 |
|
3 |
> Adds source file and line number to JSX elements.
|
4 |
|
5 |
## Example
|
6 |
|
7 |
**In**
|
8 |
|
9 |
```
|
10 |
<sometag /> |
11 |
```
|
12 |
|
13 |
**Out**
|
14 |
|
15 |
```
|
16 |
<sometag __source={ { fileName: 'this/file.js', lineNumber: 10 } } /> |
17 |
```
|
18 |
|
19 |
## Installation
|
20 |
|
21 |
```sh |
22 |
npm install --save-dev babel-plugin-transform-react-jsx-source |
23 |
```
|
24 |
|
25 |
## Usage
|
26 |
|
27 |
### Via `.babelrc` (Recommended)
|
28 |
|
29 |
**.babelrc**
|
30 |
|
31 |
```json |
32 |
{
|
33 |
"plugins": ["transform-react-jsx-source"] |
34 |
}
|
35 |
```
|
36 |
|
37 |
### Via CLI
|
38 |
|
39 |
```sh |
40 |
babel --plugins transform-react-jsx-source script.js
|
41 |
```
|
42 |
|
43 |
### Via Node API
|
44 |
|
45 |
```javascript |
46 |
require("babel-core").transform("code", { |
47 |
plugins: ["transform-react-jsx-source"] |
48 |
});
|
49 |
```
|