You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35-20Lines changed: 35 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,43 +3,47 @@
3
3
This includes the babel configuration used for JavaScript packages in atom-ide-community.
4
4
5
5
## Installation
6
+
6
7
```
7
8
npm install --save-dev babel-preset-atomic
8
9
```
9
10
10
11
You should also install the peer dependencies:
12
+
11
13
```
12
14
npm install -save-dev "@babel/core"
13
15
npm install -save-dev "@babel/cli"
14
16
```
15
17
16
18
## Usage
19
+
17
20
Create a `babel.config.js` file at the root of the project with the following content:
21
+
18
22
```js
19
-
let presets = [
20
-
"babel-preset-atomic",
21
-
];
23
+
let presets = ["babel-preset-atomic"]
22
24
23
-
let plugins = [];
25
+
let plugins = []
24
26
25
27
module.exports= {
26
28
presets: presets,
27
29
plugins: plugins,
28
30
exclude:"node_modules/**",
29
31
sourceMap:"inline",
30
-
};
32
+
}
31
33
```
32
34
33
35
## Options
34
36
35
-
1)`keepModules`
37
+
1.`keepModules`
36
38
37
39
If you want to keep the ES modules as they are (not transforming `import` to `require`), set `BABEL_KEEP_MODULES` environment variable to `true`. This is useful with bundlers which need you to keep ES6 modules intact. By default the ES6 modules are transformed to ES5 (the value is `false`)
40
+
38
41
```
39
42
cross-env BABEL_KEEP_MODULES=true
40
43
```
41
44
42
45
To permanently set this option, you can add it to your babel config (which disables environment variable effectiveness):
46
+
43
47
```js
44
48
let presets = [
45
49
[
@@ -48,26 +52,27 @@ let presets = [
48
52
keepModules:true,
49
53
},
50
54
],
51
-
];
55
+
]
52
56
```
53
57
54
-
2)`targets`
58
+
2.`targets`
55
59
56
60
To change the target of `preset-env` plugin. By default this is configured for Electron.
61
+
57
62
```js
58
63
let presets = [
59
64
[
60
65
"babel-preset-atomic",
61
66
{
62
67
targets: {
63
68
electron:6,
64
-
}
69
+
},
65
70
},
66
71
],
67
-
];
72
+
]
68
73
```
69
74
70
-
3)`addModuleExports`:
75
+
3.`addModuleExports`:
71
76
72
77
Allows to `require` a ES6 module that has exported a single thing as `default`, in a ES5 fashion without `require().default`. This is `true` by default for backward compatibility with Atom packages.
73
78
@@ -76,64 +81,74 @@ let presets = [
76
81
[
77
82
"babel-preset-atomic",
78
83
{
79
-
addModuleExports:false
84
+
addModuleExports:false,
80
85
},
81
86
],
82
-
];
87
+
]
83
88
```
84
89
85
-
4)`addModuleExportsDefaultProperty`:
90
+
4.`addModuleExportsDefaultProperty`:
86
91
87
92
```js
88
93
let presets = [
89
94
[
90
95
"babel-preset-atomic",
91
96
{
92
97
addModuleExports:true,
93
-
addModuleExportsDefaultProperty:true
98
+
addModuleExportsDefaultProperty:true,
94
99
},
95
100
],
96
-
];
101
+
]
97
102
```
98
103
99
104
Adds `default` property to `module.exports` so the ES6 module can be required in the ES6 fashion as well (by `require().default`). This is `false` by default.
100
105
101
-
6)`react`
106
+
6.`react`
102
107
103
108
Enable `"@babel/preset-react"`. `true` by default.
104
109
105
-
7)`flow`
110
+
7.`flow`
106
111
107
112
Enable `"@babel/preset-flow"`. `true` by default.
108
113
109
-
8)`removeAllUseStrict`
114
+
7.`typescript`
115
+
116
+
Enable `"@babel/preset-typescript"`. `true` by default.
117
+
118
+
9.`removeAllUseStrict`
110
119
111
120
Remove all `'use strict'` from all files. Passed to [`babel-plugin-transform-not-strict`](https://github.com/atom-ide-community/babel-plugin-transform-not-strict#usage-remove-all). This is `false` by default.
112
121
113
-
9)`notStrictDirectiveTriggers` and `notStrictCommentTriggers`
122
+
10.`notStrictDirectiveTriggers` and `notStrictCommentTriggers`
114
123
115
124
These specify `"not strict"` triggers. Passed to [`babel-plugin-transform-not-strict`](https://github.com/atom-ide-community/babel-plugin-transform-not-strict#usage-extra-directive-or-comment-triggers).
116
125
117
126
## Behind the scenes
118
127
119
128
It includes the following presets:
129
+
120
130
-`"@babel/preset-env"` (configured for `electron`)
121
131
-`"@babel/preset-react"`
122
132
-`"@babel/preset-flow"`
133
+
-`"@babel/preset-typescript"`
123
134
124
135
It also includes all the proposal plugins such as:
0 commit comments