99
1010const path = require ( 'path' )
1111const rollup = require ( 'rollup' )
12- const babel = require ( 'rollup- plugin-babel' )
12+ const { babel } = require ( '@ rollup/ plugin-babel' )
1313const banner = require ( './banner.js' )
1414
1515const plugins = [
1616 babel ( {
1717 // Only transpile our source code
1818 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'
2721 } )
2822]
2923const coreuiPlugins = {
@@ -160,7 +154,7 @@ const domObjects = [
160154 'SelectorEngine'
161155]
162156
163- function build ( plugin ) {
157+ const build = async plugin => {
164158 console . log ( `Building ${ plugin } plugin...` )
165159
166160 const { external, globals } = getConfigByPluginKey ( plugin )
@@ -175,23 +169,32 @@ function build(plugin) {
175169 pluginPath = `${ rootPath } /dom/`
176170 }
177171
178- rollup . rollup ( {
172+ const bundle = await rollup . rollup ( {
179173 input : coreuiPlugins [ plugin ] ,
180174 plugins,
181175 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 } ` ) )
193176 } )
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+ }
194198}
195199
196- Object . keys ( coreuiPlugins )
197- . forEach ( plugin => build ( plugin ) )
200+ main ( )
0 commit comments