@samitouri / QOS-React / commits / a8ab2bcb62

[rollup] Add support for running prebuild commands (#32592)

Extracting portions of #32416 for easier review. Adds a new `prebuild` option to allow for a prebuild command to be run prior to building the bundle. Co-authored-by: michael faith <michaelfaith@users.noreply.github.com> --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32592). * __->__ #32592 * #32591 * #32590 * #32589 * #32588 --------- Co-authored-by: michael faith <michaelfaith@users.noreply.github.com>

lauren committed Mar 12, 2025 at 19:12 UTC a8ab2bcb627ed7c57d2e116b2e13ad5451259c2b
1 file changed +9
scripts/rollup/build.js
+9
@@ -12,6 +12,7 @@ const stripBanner = require('rollup-plugin-strip-banner');
12 const chalk = require('chalk');
13 const resolve = require('@rollup/plugin-node-resolve').nodeResolve;
14 const fs = require('fs');
15 +const childProcess = require('child_process');
16 const argv = require('minimist')(process.argv.slice(2));
17 const Modules = require('./modules');
18 const Bundles = require('./bundles');
@@ -812,6 +813,11 @@ function handleRollupError(error) {
813 }
814 }
815
816 +function runShellCommand(command) {
817 + console.log(chalk.dim('Running: ') + chalk.cyan(command));
818 + childProcess.execSync(command, {stdio: 'inherit', shell: true});
819 +}
820 +
821 async function buildEverything() {
822 if (!argv['unsafe-partial']) {
823 await asyncRimRaf('build');
@@ -859,6 +865,9 @@ async function buildEverything() {
865
866 // eslint-disable-next-line no-for-of-loops/no-for-of-loops
867 for (const [bundle, bundleType] of bundles) {
868 + if (bundle.prebuild) {
869 + runShellCommand(bundle.prebuild);
870 + }
871 await createBundle(bundle, bundleType);
872 }
873