Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure build plugins can exit in error #30744

Merged
merged 2 commits into from May 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 25 additions & 17 deletions build/build-plugins.js
Expand Up @@ -56,7 +56,7 @@ const defaultPluginConfig = {
}
}

function getConfigByPluginKey(pluginKey) {
const getConfigByPluginKey = pluginKey => {
if (
pluginKey === 'Data' ||
pluginKey === 'Manipulator' ||
Expand Down Expand Up @@ -143,7 +143,7 @@ const domObjects = [
'SelectorEngine'
]

function build(plugin) {
const build = async plugin => {
console.log(`Building ${plugin} plugin...`)

const { external, globals } = getConfigByPluginKey(plugin)
Expand All @@ -158,24 +158,32 @@ function build(plugin) {
pluginPath = `${rootPath}/dom/`
}

rollup.rollup({
const bundle = await rollup.rollup({
input: bsPlugins[plugin],
plugins,
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!`)
}

const main = async () => {
try {
await Promise.all(Object.keys(bsPlugins).map(plugin => build(plugin)))
} catch (error) {
console.error(error)

process.exit(1)
}
}

Object.keys(bsPlugins)
.forEach(plugin => build(plugin))
main()