Skip to content

Commit 051272f

Browse files
authored
Use Entry in yarn build ... Instead of Label (facebook#14148)
* Parse build script type and package names This ensures that `yarn build core dom` includes DOM. It also ensures that spaces like `yarn build "core, dom"` doesn't build EVERYTHING. * Get rid of label in bundles config Instead we just use the name from entry using fuzzy search. There is one special case. If you put in `/index` or `/index.js`. That allows to build things like `react/index` to only build isomorphic where as `react` would build everything. Or `react-dom/index` to exclude the server renderers. * Instead of matching `/index.js` just append it to the search string That way things like `yarn build react/` works too.
1 parent 3ff2c7c commit 051272f

File tree

2 files changed

+30
-33
lines changed

2 files changed

+30
-33
lines changed

scripts/rollup/build.js

+30-7
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,30 @@ const {
5353
RN_FB_PROFILING,
5454
} = Bundles.bundleTypes;
5555

56-
const requestedBundleTypes = (argv.type || '')
57-
.split(',')
58-
.map(type => type.toUpperCase());
59-
const requestedBundleNames = (argv._[0] || '')
60-
.split(',')
61-
.map(type => type.toLowerCase());
56+
function parseRequestedNames(names, toCase) {
57+
let result = [];
58+
for (let i = 0; i < names.length; i++) {
59+
let splitNames = names[i].split(',');
60+
for (let j = 0; j < splitNames.length; j++) {
61+
let name = splitNames[j].trim();
62+
if (!name) {
63+
continue;
64+
}
65+
if (toCase === 'uppercase') {
66+
name = name.toUpperCase();
67+
} else if (toCase === 'lowercase') {
68+
name = name.toLowerCase();
69+
}
70+
result.push(name);
71+
}
72+
}
73+
return result;
74+
}
75+
76+
const requestedBundleTypes = argv.type
77+
? parseRequestedNames([argv.type], 'uppercase')
78+
: [];
79+
const requestedBundleNames = parseRequestedNames(argv._, 'lowercase');
6280
const forcePrettyOutput = argv.pretty;
6381
const syncFBSourcePath = argv['sync-fbsource'];
6482
const syncWWWPath = argv['sync-www'];
@@ -407,7 +425,12 @@ function shouldSkipBundle(bundle, bundleType) {
407425
}
408426
if (requestedBundleNames.length > 0) {
409427
const isAskingForDifferentNames = requestedBundleNames.every(
410-
requestedName => bundle.label.indexOf(requestedName) === -1
428+
// If the name ends with `something/index` we only match if the
429+
// entry ends in something. Such as `react-dom/index` only matches
430+
// `react-dom` but not `react-dom/server`. Everything else is fuzzy
431+
// search.
432+
requestedName =>
433+
(bundle.entry + '/index.js').indexOf(requestedName) === -1
411434
);
412435
if (isAskingForDifferentNames) {
413436
return true;

scripts/rollup/bundles.js

-26
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ const NON_FIBER_RENDERER = moduleTypes.NON_FIBER_RENDERER;
5656
const bundles = [
5757
/******* Isomorphic *******/
5858
{
59-
label: 'core',
6059
bundleTypes: [
6160
UMD_DEV,
6261
UMD_PROD,
@@ -75,7 +74,6 @@ const bundles = [
7574

7675
/******* React DOM *******/
7776
{
78-
label: 'dom-client',
7977
bundleTypes: [
8078
UMD_DEV,
8179
UMD_PROD,
@@ -95,7 +93,6 @@ const bundles = [
9593

9694
//******* Test Utils *******/
9795
{
98-
label: 'dom-test-utils',
9996
moduleType: RENDERER_UTILS,
10097
bundleTypes: [FB_WWW_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
10198
entry: 'react-dom/test-utils',
@@ -105,7 +102,6 @@ const bundles = [
105102

106103
/* React DOM internals required for react-native-web (e.g., to shim native events from react-dom) */
107104
{
108-
label: 'dom-unstable-native-dependencies',
109105
bundleTypes: [
110106
UMD_DEV,
111107
UMD_PROD,
@@ -122,7 +118,6 @@ const bundles = [
122118

123119
/******* React DOM Server *******/
124120
{
125-
label: 'dom-server-browser',
126121
bundleTypes: [
127122
UMD_DEV,
128123
UMD_PROD,
@@ -138,7 +133,6 @@ const bundles = [
138133
},
139134

140135
{
141-
label: 'dom-server-node',
142136
bundleTypes: [NODE_DEV, NODE_PROD],
143137
moduleType: NON_FIBER_RENDERER,
144138
entry: 'react-dom/server.node',
@@ -147,7 +141,6 @@ const bundles = [
147141

148142
/******* React ART *******/
149143
{
150-
label: 'art',
151144
bundleTypes: [
152145
UMD_DEV,
153146
UMD_PROD,
@@ -169,7 +162,6 @@ const bundles = [
169162

170163
/******* React Native *******/
171164
{
172-
label: 'native-fb',
173165
bundleTypes: [RN_FB_DEV, RN_FB_PROD, RN_FB_PROFILING],
174166
moduleType: RENDERER,
175167
entry: 'react-native-renderer',
@@ -189,7 +181,6 @@ const bundles = [
189181
},
190182

191183
{
192-
label: 'native',
193184
bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING],
194185
moduleType: RENDERER,
195186
entry: 'react-native-renderer',
@@ -210,7 +201,6 @@ const bundles = [
210201

211202
/******* React Native Fabric *******/
212203
{
213-
label: 'native-fabric-fb',
214204
bundleTypes: [RN_FB_DEV, RN_FB_PROD, RN_FB_PROFILING],
215205
moduleType: RENDERER,
216206
entry: 'react-native-renderer/fabric',
@@ -231,7 +221,6 @@ const bundles = [
231221
},
232222

233223
{
234-
label: 'native-fabric',
235224
bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING],
236225
moduleType: RENDERER,
237226
entry: 'react-native-renderer/fabric',
@@ -253,7 +242,6 @@ const bundles = [
253242

254243
/******* React Test Renderer *******/
255244
{
256-
label: 'test',
257245
bundleTypes: [FB_WWW_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
258246
moduleType: RENDERER,
259247
entry: 'react-test-renderer',
@@ -262,7 +250,6 @@ const bundles = [
262250
},
263251

264252
{
265-
label: 'test-shallow',
266253
bundleTypes: [FB_WWW_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
267254
moduleType: NON_FIBER_RENDERER,
268255
entry: 'react-test-renderer/shallow',
@@ -272,7 +259,6 @@ const bundles = [
272259

273260
/******* React Noop Renderer (used for tests) *******/
274261
{
275-
label: 'noop',
276262
bundleTypes: [NODE_DEV, NODE_PROD],
277263
moduleType: RENDERER,
278264
entry: 'react-noop-renderer',
@@ -295,7 +281,6 @@ const bundles = [
295281

296282
/******* React Noop Persistent Renderer (used for tests) *******/
297283
{
298-
label: 'noop-persistent',
299284
bundleTypes: [NODE_DEV, NODE_PROD],
300285
moduleType: RENDERER,
301286
entry: 'react-noop-renderer/persistent',
@@ -318,7 +303,6 @@ const bundles = [
318303

319304
/******* React Reconciler *******/
320305
{
321-
label: 'react-reconciler',
322306
bundleTypes: [NODE_DEV, NODE_PROD],
323307
moduleType: RECONCILER,
324308
entry: 'react-reconciler',
@@ -328,7 +312,6 @@ const bundles = [
328312

329313
/******* React Persistent Reconciler *******/
330314
{
331-
label: 'react-reconciler-persistent',
332315
bundleTypes: [NODE_DEV, NODE_PROD],
333316
moduleType: RECONCILER,
334317
entry: 'react-reconciler/persistent',
@@ -338,7 +321,6 @@ const bundles = [
338321

339322
/******* Reflection *******/
340323
{
341-
label: 'reconciler-reflection',
342324
moduleType: RENDERER_UTILS,
343325
bundleTypes: [NODE_DEV, NODE_PROD],
344326
entry: 'react-reconciler/reflection',
@@ -348,7 +330,6 @@ const bundles = [
348330

349331
/******* React Is *******/
350332
{
351-
label: 'react-is',
352333
bundleTypes: [
353334
NODE_DEV,
354335
NODE_PROD,
@@ -365,7 +346,6 @@ const bundles = [
365346

366347
/******* React Debug Tools *******/
367348
{
368-
label: 'react-debug-tools',
369349
bundleTypes: [NODE_DEV, NODE_PROD],
370350
moduleType: ISOMORPHIC,
371351
entry: 'react-debug-tools',
@@ -375,7 +355,6 @@ const bundles = [
375355

376356
/******* React Cache (experimental) *******/
377357
{
378-
label: 'react-cache',
379358
bundleTypes: [
380359
FB_WWW_DEV,
381360
FB_WWW_PROD,
@@ -392,7 +371,6 @@ const bundles = [
392371

393372
/******* createComponentWithSubscriptions (experimental) *******/
394373
{
395-
label: 'create-subscription',
396374
bundleTypes: [NODE_DEV, NODE_PROD],
397375
moduleType: ISOMORPHIC,
398376
entry: 'create-subscription',
@@ -402,7 +380,6 @@ const bundles = [
402380

403381
/******* React Scheduler (experimental) *******/
404382
{
405-
label: 'scheduler',
406383
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
407384
moduleType: ISOMORPHIC,
408385
entry: 'scheduler',
@@ -412,7 +389,6 @@ const bundles = [
412389

413390
/******* Jest React (experimental) *******/
414391
{
415-
label: 'jest-react',
416392
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
417393
moduleType: ISOMORPHIC,
418394
entry: 'jest-react',
@@ -422,7 +398,6 @@ const bundles = [
422398

423399
/******* ESLint Plugin for Hooks (proposal) *******/
424400
{
425-
label: 'eslint-plugin-react-hooks',
426401
// TODO: it's awkward to create a bundle for this
427402
// but if we don't, the package won't get copied.
428403
// We also can't create just DEV bundle because
@@ -436,7 +411,6 @@ const bundles = [
436411
},
437412

438413
{
439-
label: 'scheduler-tracing',
440414
bundleTypes: [
441415
FB_WWW_DEV,
442416
FB_WWW_PROD,

0 commit comments

Comments
 (0)