Skip to content

Commit 1aa4b80

Browse files
committed
build: update rollup
1 parent 5749f86 commit 1aa4b80

File tree

2 files changed

+39
-34
lines changed

2 files changed

+39
-34
lines changed

build/build-plugins.js

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,15 @@
99

1010
const path = require('path')
1111
const rollup = require('rollup')
12-
const babel = require('rollup-plugin-babel')
12+
const { babel } = require('@rollup/plugin-babel')
1313
const banner = require('./banner.js')
1414

1515
const 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
]
2923
const 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()

build/rollup.config.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
const path = require('path')
4-
const babel = require('rollup-plugin-babel')
4+
const { babel } = require('@rollup/plugin-babel')
55
const resolve = require('@rollup/plugin-node-resolve')
66
const banner = require('./banner.js')
77
const replace = require('@rollup/plugin-replace')
@@ -15,16 +15,18 @@ const plugins = [
1515
babel({
1616
// Only transpile our source code
1717
exclude: 'node_modules/**',
18+
// Include the helpers in the bundle, at most one copy of each
19+
babelHelpers: 'bundled'
1820
// Include only required helpers
19-
externalHelpersWhitelist: [
20-
'createClass',
21-
'createSuper',
22-
'defineProperties',
23-
'defineProperty',
24-
'getPrototypeOf',
25-
'inheritsLoose',
26-
'objectSpread2'
27-
]
21+
// externalHelpersWhitelist: [
22+
// 'createClass',
23+
// 'createSuper',
24+
// 'defineProperties',
25+
// 'defineProperty',
26+
// 'getPrototypeOf',
27+
// 'inheritsLoose',
28+
// 'objectSpread2'
29+
// ]
2830
}),
2931
replace({
3032
'process.env.NODE_ENV': JSON.stringify('production')

0 commit comments

Comments
 (0)