summaryrefslogtreecommitdiffstats
path: root/build/build-plugins.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-15 11:37:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-15 11:37:20 +0000
commit22daa00afb1a5d628e0267fba0f062c4f8fb5613 (patch)
treec954c1be5487c69839459d79d74f139e3ae28011 /build/build-plugins.js
parentAdding upstream version 5.3.1+dfsg. (diff)
downloadbootstrap-html-upstream.tar.xz
bootstrap-html-upstream.zip
Adding upstream version 5.3.2+dfsg.upstream/5.3.2+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'build/build-plugins.js')
-rw-r--r--build/build-plugins.js103
1 files changed, 0 insertions, 103 deletions
diff --git a/build/build-plugins.js b/build/build-plugins.js
deleted file mode 100644
index b2833a3..0000000
--- a/build/build-plugins.js
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/usr/bin/env node
-
-/*!
- * Script to build our plugins to use them separately.
- * Copyright 2020-2023 The Bootstrap Authors
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
- */
-
-'use strict'
-
-const path = require('node:path')
-const rollup = require('rollup')
-const globby = require('globby')
-const { babel } = require('@rollup/plugin-babel')
-const banner = require('./banner.js')
-
-const sourcePath = path.resolve(__dirname, '../js/src/').replace(/\\/g, '/')
-const jsFiles = globby.sync(`${sourcePath}/**/*.js`)
-
-// Array which holds the resolved plugins
-const resolvedPlugins = []
-
-// Trims the "js" extension and uppercases => first letter, hyphens, backslashes & slashes
-const filenameToEntity = filename => filename.replace('.js', '')
- .replace(/(?:^|-|\/|\\)[a-z]/g, str => str.slice(-1).toUpperCase())
-
-for (const file of jsFiles) {
- resolvedPlugins.push({
- src: file,
- dist: file.replace('src', 'dist'),
- fileName: path.basename(file),
- className: filenameToEntity(path.basename(file))
- // safeClassName: filenameToEntity(path.relative(sourcePath, file))
- })
-}
-
-const build = async plugin => {
- const globals = {}
-
- const bundle = await rollup.rollup({
- input: plugin.src,
- plugins: [
- babel({
- // Only transpile our source code
- exclude: 'node_modules/**',
- // Include the helpers in each file, at most one copy of each
- babelHelpers: 'bundled'
- })
- ],
- external(source) {
- // Pattern to identify local files
- const pattern = /^(\.{1,2})\//
-
- // It's not a local file, e.g a Node.js package
- if (!pattern.test(source)) {
- globals[source] = source
- return true
- }
-
- const usedPlugin = resolvedPlugins.find(plugin => {
- return plugin.src.includes(source.replace(pattern, ''))
- })
-
- if (!usedPlugin) {
- throw new Error(`Source ${source} is not mapped!`)
- }
-
- // We can change `Index` with `UtilIndex` etc if we use
- // `safeClassName` instead of `className` everywhere
- globals[path.normalize(usedPlugin.src)] = usedPlugin.className
- return true
- }
- })
-
- await bundle.write({
- banner: banner(plugin.fileName),
- format: 'umd',
- name: plugin.className,
- sourcemap: true,
- globals,
- generatedCode: 'es2015',
- file: plugin.dist
- })
-
- console.log(`Built ${plugin.className}`)
-}
-
-(async () => {
- try {
- const basename = path.basename(__filename)
- const timeLabel = `[${basename}] finished`
-
- console.log('Building individual plugins...')
- console.time(timeLabel)
-
- await Promise.all(Object.values(resolvedPlugins).map(plugin => build(plugin)))
-
- console.timeEnd(timeLabel)
- } catch (error) {
- console.error(error)
- process.exit(1)
- }
-})()