ensure build plugins can exit in error (#30744)

Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
Johann-S 2020-05-06 06:52:06 +02:00 committed by GitHub
parent f91788548c
commit d1575b6b6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 17 deletions

View File

@ -56,7 +56,7 @@ const defaultPluginConfig = {
} }
} }
function getConfigByPluginKey(pluginKey) { const getConfigByPluginKey = pluginKey => {
if ( if (
pluginKey === 'Data' || pluginKey === 'Data' ||
pluginKey === 'Manipulator' || pluginKey === 'Manipulator' ||
@ -143,7 +143,7 @@ const domObjects = [
'SelectorEngine' 'SelectorEngine'
] ]
function build(plugin) { const build = async plugin => {
console.log(`Building ${plugin} plugin...`) console.log(`Building ${plugin} plugin...`)
const { external, globals } = getConfigByPluginKey(plugin) const { external, globals } = getConfigByPluginKey(plugin)
@ -158,24 +158,32 @@ function build(plugin) {
pluginPath = `${rootPath}/dom/` pluginPath = `${rootPath}/dom/`
} }
rollup.rollup({ const bundle = await rollup.rollup({
input: bsPlugins[plugin], input: bsPlugins[plugin],
plugins, plugins,
external external
}).then(bundle => {
bundle.write({
banner: banner(pluginFilename),
format: 'umd',
name: plugin,
sourcemap: true,
globals,
file: path.resolve(__dirname, `${pluginPath}/${pluginFilename}`)
})
.then(() => console.log(`Building ${plugin} plugin... Done!`))
.catch(error => console.error(`${plugin}: ${error}`))
}) })
.catch(error => console.error(`${plugin}: ${error}`))
await bundle.write({
banner: banner(pluginFilename),
format: 'umd',
name: plugin,
sourcemap: true,
globals,
file: path.resolve(__dirname, `${pluginPath}/${pluginFilename}`)
})
console.log(`Building ${plugin} plugin... Done!`)
} }
Object.keys(bsPlugins) const main = async () => {
.forEach(plugin => build(plugin)) try {
await Promise.all(Object.keys(bsPlugins).map(plugin => build(plugin)))
} catch (error) {
console.error(error)
process.exit(1)
}
}
main()