9
9
10
10
const path = require ( 'path' )
11
11
const rollup = require ( 'rollup' )
12
- const babel = require ( 'rollup- plugin-babel' )
12
+ const { babel } = require ( '@ rollup/ plugin-babel' )
13
13
const banner = require ( './banner.js' )
14
14
15
15
const plugins = [
16
16
babel ( {
17
17
// Only transpile our source code
18
18
exclude : 'node_modules/**' ,
19
- // Include only required helpers
20
- externalHelpersWhitelist : [
21
- 'defineProperties' ,
22
- 'createClass' ,
23
- 'inheritsLoose' ,
24
- 'defineProperty' ,
25
- 'objectSpread2'
26
- ]
19
+ // Inline the required helpers in each file
20
+ babelHelpers : 'inline'
27
21
} )
28
22
]
29
23
const coreuiPlugins = {
@@ -160,7 +154,7 @@ const domObjects = [
160
154
'SelectorEngine'
161
155
]
162
156
163
- function build ( plugin ) {
157
+ const build = async plugin => {
164
158
console . log ( `Building ${ plugin } plugin...` )
165
159
166
160
const { external, globals } = getConfigByPluginKey ( plugin )
@@ -175,23 +169,32 @@ function build(plugin) {
175
169
pluginPath = `${ rootPath } /dom/`
176
170
}
177
171
178
- rollup . rollup ( {
172
+ const bundle = await rollup . rollup ( {
179
173
input : coreuiPlugins [ plugin ] ,
180
174
plugins,
181
175
external
182
- } ) . then ( bundle => {
183
- bundle . write ( {
184
- banner : banner ( pluginFilename ) ,
185
- format : 'umd' ,
186
- name : plugin ,
187
- sourcemap : true ,
188
- globals,
189
- file : path . resolve ( __dirname , `${ pluginPath } /${ pluginFilename } ` )
190
- } )
191
- . then ( ( ) => console . log ( `Building ${ plugin } plugin... Done!` ) )
192
- . catch ( error => console . error ( `${ plugin } : ${ error } ` ) )
193
176
} )
177
+
178
+ await bundle . write ( {
179
+ banner : banner ( pluginFilename ) ,
180
+ format : 'umd' ,
181
+ name : plugin ,
182
+ sourcemap : true ,
183
+ globals,
184
+ file : path . resolve ( __dirname , `${ pluginPath } /${ pluginFilename } ` )
185
+ } )
186
+
187
+ console . log ( `Building ${ plugin } plugin... Done!` )
188
+ }
189
+
190
+ const main = async ( ) => {
191
+ try {
192
+ await Promise . all ( Object . keys ( coreuiPlugins ) . map ( plugin => build ( plugin ) ) )
193
+ } catch ( error ) {
194
+ console . error ( error )
195
+
196
+ process . exit ( 1 )
197
+ }
194
198
}
195
199
196
- Object . keys ( coreuiPlugins )
197
- . forEach ( plugin => build ( plugin ) )
200
+ main ( )
0 commit comments