diff options
Diffstat (limited to 'vendor/twbs/bootstrap/build/build-plugins.js')
-rw-r--r-- | vendor/twbs/bootstrap/build/build-plugins.js | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/vendor/twbs/bootstrap/build/build-plugins.js b/vendor/twbs/bootstrap/build/build-plugins.js index 877621636..9e4f2e1c3 100644 --- a/vendor/twbs/bootstrap/build/build-plugins.js +++ b/vendor/twbs/bootstrap/build/build-plugins.js @@ -1,7 +1,9 @@ +#!/usr/bin/env node + /*! * Script to build our plugins to use them separately. - * Copyright 2019 The Bootstrap Authors - * Copyright 2019 Twitter, Inc. + * Copyright 2020 The Bootstrap Authors + * Copyright 2020 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) */ @@ -11,18 +13,15 @@ const path = require('path') const rollup = require('rollup') const babel = require('rollup-plugin-babel') const banner = require('./banner.js') +const babelHelpers = require('./babel-helpers.js') const TEST = process.env.NODE_ENV === 'test' const plugins = [ babel({ - exclude: 'node_modules/**', // Only transpile our source code - externalHelpersWhitelist: [ // Include only required helpers - 'defineProperties', - 'createClass', - 'inheritsLoose', - 'defineProperty', - 'objectSpread2' - ] + // Only transpile our source code + exclude: 'node_modules/**', + // Include only required helpers + externalHelpersWhitelist: babelHelpers }) ] const bsPlugins = { @@ -41,7 +40,7 @@ const bsPlugins = { } const rootPath = TEST ? '../js/coverage/dist/' : '../js/dist/' -function build(plugin) { +const build = async (plugin) => { console.log(`Building ${plugin} plugin...`) const external = ['jquery', 'popper.js'] @@ -63,23 +62,32 @@ function build(plugin) { } const pluginFilename = `${plugin.toLowerCase()}.js` - - 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, `${rootPath}${pluginFilename}`) - }) - .then(() => console.log(`Building ${plugin} plugin... Done!`)) - .catch((err) => console.error(`${plugin}: ${err}`)) }) + + await bundle.write({ + banner: banner(pluginFilename), + format: 'umd', + name: plugin, + sourcemap: true, + globals, + file: path.resolve(__dirname, `${rootPath}${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() |