Skip to content

Commit f6cce07

Browse files
authored
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.
1 parent 7048484 commit f6cce07

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

scripts/rollup/build-all-release-channels.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const {
1717
} = require('../../ReactVersions');
1818
const yargs = require('yargs');
1919
const {buildEverything} = require('./build-ghaction');
20+
const Bundles = require('./bundles');
2021

2122
// Runs the build script for both stable and experimental release channels,
2223
// by configuring an environment variable.
@@ -79,6 +80,37 @@ const argv = yargs.wrap(yargs.terminalWidth()).options({
7980
type: 'choices',
8081
choices: ['circleci', 'github'],
8182
},
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+
},
82114
}).argv;
83115

84116
async function main() {

scripts/rollup/build.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ function parseRequestedNames(names, toCase) {
8484
}
8585
return result;
8686
}
87+
const argvType = Array.isArray(argv.bundle) ? argv.bundle : [argv.bundle];
88+
const requestedBundleTypes = argv.bundle ? argvType : [];
8789

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+
);
9494
const forcePrettyOutput = argv.pretty;
9595
const isWatchMode = argv.watch;
9696
const syncFBSourcePath = argv['sync-fbsource'];

0 commit comments

Comments
 (0)