1
- const { declare } = require ( " @babel/helper-plugin-utils" ) ;
2
- const isModuleAvailable = require ( './lib/is-module-available' ) ;
3
- const missing = require ( './lib/missing' ) ;
1
+ import { declare } from ' @babel/helper-plugin-utils' ;
2
+ import isModuleAvailable from './lib/is-module-available.js' ;
3
+ import missing from './lib/missing.js' ;
4
4
5
- module . exports = declare ( ( api , options ) => {
5
+ const bable = declare ( ( api , options ) => {
6
6
// see docs about api at https://babeljs.io/docs/en/config-files#apicache
7
- api . assertVersion ( " ^7.0.0" ) ;
7
+ api . assertVersion ( ' ^7.13' ) ;
8
8
9
9
const {
10
- modules = " auto" ,
10
+ modules = ' auto' ,
11
11
targets = null ,
12
12
removePropTypes = false ,
13
13
looseClasses = false ,
@@ -21,14 +21,14 @@ module.exports = declare((api, options) => {
21
21
runtimeHelpersUseESModules = ! modules ,
22
22
} = options ;
23
23
24
- if ( typeof modules !== " undefined" && typeof modules !== " boolean" && modules !== " auto" ) {
24
+ if ( typeof modules !== ' undefined' && typeof modules !== ' boolean' && modules !== ' auto' ) {
25
25
throw new TypeError (
26
26
'@anolilab/babel-preset only accepts `true`, `false`, or `"auto"` as the value of the "modules" option' ,
27
27
) ;
28
28
}
29
29
30
30
if ( removePropTypes && ! react ) {
31
- throw new Error ( '" removePropTypes" can\'t be enabled if react is disabled.' )
31
+ throw new Error ( 'removePropTypes can\'t be enabled if react is disabled.' )
32
32
}
33
33
34
34
let install = [ ]
@@ -61,62 +61,62 @@ module.exports = declare((api, options) => {
61
61
missing ( install )
62
62
}
63
63
64
- const debug = typeof options . debug === " boolean" ? options . debug : false ;
64
+ const debug = typeof options . debug === ' boolean' ? options . debug : false ;
65
65
const development =
66
- typeof options . development === " boolean"
66
+ typeof options . development === ' boolean'
67
67
? options . development
68
- : api . cache . using ( ( ) => process . env . NODE_ENV === " development" ) ;
68
+ : process . env . NODE_ENV === ' development' ;
69
69
70
70
return {
71
71
presets : [
72
72
[
73
- require ( " @babel/preset-env" ) ,
73
+ ' @babel/preset-env' ,
74
74
{
75
75
debug,
76
- exclude : [ " transform-async-to-generator" , " transform-regenerator" ] ,
77
- modules : modules === false ? false : " auto" ,
76
+ exclude : [ ' transform-async-to-generator' , ' transform-regenerator' ] ,
77
+ modules : modules === false ? false : ' auto' ,
78
78
targets : targets ,
79
79
} ,
80
80
] ,
81
81
typescript
82
82
? [
83
- require ( " @babel/preset-typescript" ) ,
83
+ ' @babel/preset-typescript' ,
84
84
{
85
85
allExtensions : true ,
86
86
isTSX : true ,
87
87
} ,
88
88
]
89
89
: null ,
90
- react ? [ require ( " @babel/preset-react" ) , { development } ] : null ,
90
+ react ? [ ' @babel/preset-react' , { development } ] : null ,
91
91
] . filter ( Boolean ) ,
92
92
plugins : [
93
93
// class { handleClick = () => { } }
94
94
// Enable loose mode to use assignment instead of defineProperty
95
95
// See discussion in https://github.com/facebook/create-react-app/issues/4263
96
96
[
97
- require ( " @babel/plugin-proposal-class-properties" ) ,
97
+ ' @babel/plugin-proposal-class-properties' ,
98
98
{
99
99
loose : true ,
100
100
} ,
101
101
] ,
102
102
looseClasses
103
103
? [
104
- require ( " @babel/plugin-transform-classes" ) ,
104
+ ' @babel/plugin-transform-classes' ,
105
105
{
106
106
loose : true ,
107
107
} ,
108
108
]
109
109
: null ,
110
110
[
111
- require ( " @babel/plugin-proposal-decorators" ) ,
111
+ ' @babel/plugin-proposal-decorators' ,
112
112
{
113
113
legacy : true ,
114
114
} ,
115
115
] ,
116
116
// https://babeljs.io/docs/en/babel-plugin-transform-computed-properties#loose
117
117
looseComputedProperties
118
118
? [
119
- require ( " @babel/plugin-transform-computed-properties" ) ,
119
+ ' @babel/plugin-transform-computed-properties' ,
120
120
{
121
121
loose : true ,
122
122
} ,
@@ -125,7 +125,7 @@ module.exports = declare((api, options) => {
125
125
// https://babeljs.io/docs/en/babel-plugin-transform-parameters#loose
126
126
looseParameters
127
127
? [
128
- require ( " @babel/plugin-transform-parameters" ) ,
128
+ ' @babel/plugin-transform-parameters' ,
129
129
{
130
130
loose : true ,
131
131
} ,
@@ -134,62 +134,58 @@ module.exports = declare((api, options) => {
134
134
// https://babeljs.io/docs/en/next/babel-plugin-transform-template-literals.html#loose
135
135
looseTemplateLiterals
136
136
? [
137
- require ( " @babel/plugin-transform-template-literals" ) ,
137
+ ' @babel/plugin-transform-template-literals' ,
138
138
{
139
139
loose : false ,
140
140
} ,
141
141
]
142
142
: null ,
143
143
react && removePropTypes
144
144
? [
145
- require ( " babel-plugin-transform-react-remove-prop-types" ) ,
145
+ ' babel-plugin-transform-react-remove-prop-types' ,
146
146
Object . assign (
147
147
{
148
- mode : " wrap" ,
149
- ignoreFilenames : [ " node_modules" ] ,
148
+ mode : ' wrap' ,
149
+ ignoreFilenames : [ ' node_modules' ] ,
150
150
} ,
151
151
removePropTypes ,
152
152
) ,
153
153
]
154
154
: null ,
155
- require ( '@babel/plugin-proposal-export-namespace-from' ) ,
156
- typescript ? require ( " @babel/plugin-transform-typescript" ) : null ,
155
+ '@babel/plugin-proposal-export-namespace-from' ,
156
+ typescript ? ' @babel/plugin-transform-typescript' : null ,
157
157
// Transform dynamic import to require
158
158
[
159
- require ( " babel-plugin-dynamic-import-node" ) ,
159
+ ' babel-plugin-dynamic-import-node' ,
160
160
{
161
161
noInterop : true ,
162
162
} ,
163
163
] ,
164
- typescript ? require ( '@babel/plugin-syntax-jsx' ) : null ,
164
+ typescript ? '@babel/plugin-syntax-jsx' : null ,
165
165
// Adds syntax support for import()
166
- require ( "@babel/plugin-syntax-dynamic-import" ) ,
167
- require ( "@babel/plugin-transform-property-mutators" ) ,
168
- require ( "@babel/plugin-transform-member-expression-literals" ) ,
169
- require ( "@babel/plugin-transform-property-literals" ) ,
170
- require ( "@babel/plugin-proposal-nullish-coalescing-operator" ) ,
171
- require ( "@babel/plugin-proposal-numeric-separator" ) ,
172
- require ( "@babel/plugin-syntax-bigin" ) ,
173
- require ( "@babel/plugin-proposal-optional-catch-binding" ) ,
174
- require ( "@babel/plugin-proposal-optional-chaining" ) ,
175
- require ( "@babel/plugin-syntax-bigint" ) ,
166
+ '@babel/plugin-syntax-dynamic-import' ,
167
+ '@babel/plugin-transform-property-mutators' ,
168
+ '@babel/plugin-transform-member-expression-literals' ,
169
+ '@babel/plugin-transform-property-literals' ,
170
+ '@babel/plugin-proposal-nullish-coalescing-operator' ,
171
+ '@babel/plugin-proposal-numeric-separator' ,
172
+ '@babel/plugin-proposal-optional-catch-binding' ,
173
+ '@babel/plugin-proposal-optional-chaining' ,
174
+ '@babel/plugin-syntax-bigint' ,
176
175
[
177
- require ( " @babel/plugin-proposal-object-rest-spread" ) ,
176
+ ' @babel/plugin-proposal-object-rest-spread' ,
178
177
{
179
178
useBuiltIns : true ,
180
179
} ,
181
180
] ,
182
181
// https://babeljs.io/docs/en/babel-plugin-syntax-async-generators
183
- require ( "@babel/plugin-syntax-async-generators" ) ,
184
- // fast-async is a Babel plugin that implements the ES7 keywords async and await
185
- // using syntax transformation at compile-time, rather than generators.
186
- require ( "fast-async" ) ,
182
+ '@babel/plugin-syntax-async-generators' ,
187
183
// Experimental macros support. Will be documented after it's had some time
188
184
// in the wild.
189
- require ( " babel-plugin-macros" ) ,
185
+ ' babel-plugin-macros' ,
190
186
transformRuntime
191
187
? [
192
- require ( " @babel/plugin-transform-runtime" ) ,
188
+ ' @babel/plugin-transform-runtime' ,
193
189
{
194
190
absoluteRuntime : false ,
195
191
corejs : false ,
@@ -203,3 +199,5 @@ module.exports = declare((api, options) => {
203
199
] . filter ( Boolean ) ,
204
200
} ;
205
201
} ) ;
202
+
203
+ export default bable
0 commit comments