-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
chore(build): Parallelize CDN bundle builds #20334
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
base: develop
Are you sure you want to change the base?
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* eslint-disable no-console */ | ||
|
|
||
| /** | ||
| * Runs rollup builds in parallel for configs that export an array. | ||
| * Usage: node rollupParallel.mjs <config-path> | ||
| */ | ||
| import { availableParallelism } from 'os'; | ||
| import { pathToFileURL } from 'url'; | ||
| import { resolve } from 'path'; | ||
| import { rollup } from 'rollup'; | ||
|
|
||
| const configPath = process.argv[2]; | ||
| if (!configPath) { | ||
| console.error('Usage: node rollupParallel.mjs <config-path>'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const { default: configs } = await import(pathToFileURL(resolve(configPath)).href); | ||
| const concurrency = availableParallelism(); | ||
| const queue = [...configs]; | ||
| let done = 0; | ||
|
|
||
| async function worker() { | ||
| while (queue.length > 0) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. l: We could abort once a worker failed.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm not sure what would be more helpful here actually 🤔 but I suppose if |
||
| const config = queue.shift(); | ||
| const bundle = await rollup({ ...config, onwarn: console.warn }); | ||
| await bundle.write(config.output); | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| await bundle.close(); | ||
| done++; | ||
| process.stdout.write(`\r [${done}/${configs.length}] builds completed`); | ||
| } | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| } | ||
|
|
||
| console.log(`Running ${configs.length} rollup builds (concurrency: ${concurrency})...`); | ||
| await Promise.all(Array.from({ length: concurrency }, worker)); | ||
| console.log('\nDone.'); | ||
Uh oh!
There was an error while loading. Please reload this page.