@samitouri / QOS-React / commits / f6cce072cf

Update yarn build options (#30422)

Improve command documentation and make it easier to build specific bundle types **Before** ``` % yarn build --help yarn run v1.22.19 $ node ./scripts/rollup/build-all-release-channels.js --help Options: --help Show help [boolean] --version Show version number [boolean] --releaseChannel, -r Build the given release channel. [string] [choices: "experimental", "stable"] --index, -i Worker id. [number] --total, -t Total number of workers. [number] --ci Run tests in CI [choices: "circleci", "github"] ✨ Done in 0.69s. ``` **After** ``` % yarn build --help yarn run v1.22.19 $ node ./scripts/rollup/build-all-release-channels.js --help Options: --help Show help [boolean] --version Show version number [boolean] --releaseChannel, -r Build the given release channel. [string] [choices: "experimental", "stable"] --index, -i Worker id. [number] --total, -t Total number of workers. [number] --bundle Build the given bundle type. [choices: "NODE_ES2015", "ESM_DEV", "ESM_PROD", "NODE_DEV", "NODE_PROD", "NODE_PROFILING", "BUN_DEV", "BUN_PROD", "FB_WWW_DEV", "FB_WWW_PROD", "FB_WWW_PROFILING", "RN_OSS_DEV", "RN_OSS_PROD", "RN_OSS_PROFILING", "RN_FB_DEV", "RN_FB_PROD", "RN_FB_PROFILING", "BROWSER_SCRIPT"] --ci Run tests in CI [choices: "circleci", "github"] --names Build for matched bundle names. Example: "react-test,index.js". [array] --pretty Force pretty output. [boolean] --sync-fbsource Include to sync build to fbsource. [string] --sync-www Include to sync build to www. [string] --unsafe-partial Do not clean ./build first. [boolean] ✨ Done in 0.61s. ``` Changes - Use yargs to document existing options: `pretty`, `sync-fbsource`, `sync-www`, `unsafe-partial`. - Move `_` arg to `names` option for consistency with other options and discoverability through yargs help - Add `bundle` option in place of `argv.type` that allows choices of any BundleType to be passed in directly.

Jack Pope committed Jul 23, 2024 at 11:27 UTC f6cce072cf831573a29849b4146f6bab51f85380
2 files changed +38 -6
scripts/rollup/build-all-release-channels.js
+32
@@ -17,6 +17,7 @@ const {
17 } = require('../../ReactVersions');
18 const yargs = require('yargs');
19 const {buildEverything} = require('./build-ghaction');
20 +const Bundles = require('./bundles');
21
22 // Runs the build script for both stable and experimental release channels,
23 // by configuring an environment variable.
@@ -79,6 +80,37 @@ const argv = yargs.wrap(yargs.terminalWidth()).options({
80 type: 'choices',
81 choices: ['circleci', 'github'],
82 },
83 + bundle: {
84 + describe: 'Build the given bundle type.',
85 + requiresArg: false,
86 + type: 'choices',
87 + choices: [...Object.values(Bundles.bundleTypes)],
88 + },
89 + names: {
90 + describe: 'Build for matched bundle names. Example: "react-test,index.js".',
91 + requiresArg: false,
92 + type: 'array',
93 + },
94 + pretty: {
95 + describe: 'Force pretty output.',
96 + requiresArg: false,
97 + type: 'boolean',
98 + },
99 + 'sync-fbsource': {
100 + describe: 'Include to sync build to fbsource.',
101 + requiresArg: false,
102 + type: 'string',
103 + },
104 + 'sync-www': {
105 + describe: 'Include to sync build to www.',
106 + requiresArg: false,
107 + type: 'string',
108 + },
109 + 'unsafe-partial': {
110 + describe: 'Do not clean ./build first.',
111 + requiresArg: false,
112 + type: 'boolean',
113 + },
114 }).argv;
115
116 async function main() {
scripts/rollup/build.js
+6 -6
@@ -84,13 +84,13 @@ function parseRequestedNames(names, toCase) {
84 }
85 return result;
86 }
87 +const argvType = Array.isArray(argv.bundle) ? argv.bundle : [argv.bundle];
88 +const requestedBundleTypes = argv.bundle ? argvType : [];
89
88 -const argvType = Array.isArray(argv.type) ? argv.type : [argv.type];
89 -const requestedBundleTypes = argv.type
90 - ? parseRequestedNames(argvType, 'uppercase')
91 - : [];
92 -
93 -const requestedBundleNames = parseRequestedNames(argv._, 'lowercase');
90 +const requestedBundleNames = parseRequestedNames(
91 + argv.names ? argv.names : [],
92 + 'lowercase'
93 +);
94 const forcePrettyOutput = argv.pretty;
95 const isWatchMode = argv.watch;
96 const syncFBSourcePath = argv['sync-fbsource'];