Use Entry in `yarn build ...` Instead of Label (#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.
Sebastian Markbåge committed
Nov 7, 2018 at 20:46 UTC
051272f2012e1c2f75dc8ee9fe72a1d85cdac302
2 files changed
+30
-33
scripts/rollup/build.js
+30
-7
@@ -53,12 +53,30 @@ const {
53
RN_FB_PROFILING,
54
} = Bundles.bundleTypes;
55
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');
80
const forcePrettyOutput = argv.pretty;
81
const syncFBSourcePath = argv['sync-fbsource'];
82
const syncWWWPath = argv['sync-www'];
@@ -407,7 +425,12 @@ function shouldSkipBundle(bundle, bundleType) {
425
}
426
if (requestedBundleNames.length > 0) {
427
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
434
);
435
if (isAskingForDifferentNames) {
436
return true;
scripts/rollup/bundles.js
-26
@@ -56,7 +56,6 @@ const NON_FIBER_RENDERER = moduleTypes.NON_FIBER_RENDERER;
56
const bundles = [
57
/******* Isomorphic *******/
58
{
59
- label: 'core',
59
bundleTypes: [
60
UMD_DEV,
61
UMD_PROD,
@@ -75,7 +74,6 @@ const bundles = [
74
75
/******* React DOM *******/
76
{
78
- label: 'dom-client',
77
bundleTypes: [
78
UMD_DEV,
79
UMD_PROD,
@@ -95,7 +93,6 @@ const bundles = [
93
94
//******* Test Utils *******/
95
{
98
- label: 'dom-test-utils',
96
moduleType: RENDERER_UTILS,
97
bundleTypes: [FB_WWW_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
98
entry: 'react-dom/test-utils',
@@ -105,7 +102,6 @@ const bundles = [
102
103
/* React DOM internals required for react-native-web (e.g., to shim native events from react-dom) */
104
{
108
- label: 'dom-unstable-native-dependencies',
105
bundleTypes: [
106
UMD_DEV,
107
UMD_PROD,
@@ -122,7 +118,6 @@ const bundles = [
118
119
/******* React DOM Server *******/
120
{
125
- label: 'dom-server-browser',
121
bundleTypes: [
122
UMD_DEV,
123
UMD_PROD,
@@ -138,7 +133,6 @@ const bundles = [
133
},
134
135
{
141
- label: 'dom-server-node',
136
bundleTypes: [NODE_DEV, NODE_PROD],
137
moduleType: NON_FIBER_RENDERER,
138
entry: 'react-dom/server.node',
@@ -147,7 +141,6 @@ const bundles = [
141
142
/******* React ART *******/
143
{
150
- label: 'art',
144
bundleTypes: [
145
UMD_DEV,
146
UMD_PROD,
@@ -169,7 +162,6 @@ const bundles = [
162
163
/******* React Native *******/
164
{
172
- label: 'native-fb',
165
bundleTypes: [RN_FB_DEV, RN_FB_PROD, RN_FB_PROFILING],
166
moduleType: RENDERER,
167
entry: 'react-native-renderer',
@@ -189,7 +181,6 @@ const bundles = [
181
},
182
183
{
192
- label: 'native',
184
bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING],
185
moduleType: RENDERER,
186
entry: 'react-native-renderer',
@@ -210,7 +201,6 @@ const bundles = [
201
202
/******* React Native Fabric *******/
203
{
213
- label: 'native-fabric-fb',
204
bundleTypes: [RN_FB_DEV, RN_FB_PROD, RN_FB_PROFILING],
205
moduleType: RENDERER,
206
entry: 'react-native-renderer/fabric',
@@ -231,7 +221,6 @@ const bundles = [
221
},
222
223
{
234
- label: 'native-fabric',
224
bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING],
225
moduleType: RENDERER,
226
entry: 'react-native-renderer/fabric',
@@ -253,7 +242,6 @@ const bundles = [
242
243
/******* React Test Renderer *******/
244
{
256
- label: 'test',
245
bundleTypes: [FB_WWW_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
246
moduleType: RENDERER,
247
entry: 'react-test-renderer',
@@ -262,7 +250,6 @@ const bundles = [
250
},
251
252
{
265
- label: 'test-shallow',
253
bundleTypes: [FB_WWW_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
254
moduleType: NON_FIBER_RENDERER,
255
entry: 'react-test-renderer/shallow',
@@ -272,7 +259,6 @@ const bundles = [
259
260
/******* React Noop Renderer (used for tests) *******/
261
{
275
- label: 'noop',
262
bundleTypes: [NODE_DEV, NODE_PROD],
263
moduleType: RENDERER,
264
entry: 'react-noop-renderer',
@@ -295,7 +281,6 @@ const bundles = [
281
282
/******* React Noop Persistent Renderer (used for tests) *******/
283
{
298
- label: 'noop-persistent',
284
bundleTypes: [NODE_DEV, NODE_PROD],
285
moduleType: RENDERER,
286
entry: 'react-noop-renderer/persistent',
@@ -318,7 +303,6 @@ const bundles = [
303
304
/******* React Reconciler *******/
305
{
321
- label: 'react-reconciler',
306
bundleTypes: [NODE_DEV, NODE_PROD],
307
moduleType: RECONCILER,
308
entry: 'react-reconciler',
@@ -328,7 +312,6 @@ const bundles = [
312
313
/******* React Persistent Reconciler *******/
314
{
331
- label: 'react-reconciler-persistent',
315
bundleTypes: [NODE_DEV, NODE_PROD],
316
moduleType: RECONCILER,
317
entry: 'react-reconciler/persistent',
@@ -338,7 +321,6 @@ const bundles = [
321
322
/******* Reflection *******/
323
{
341
- label: 'reconciler-reflection',
324
moduleType: RENDERER_UTILS,
325
bundleTypes: [NODE_DEV, NODE_PROD],
326
entry: 'react-reconciler/reflection',
@@ -348,7 +330,6 @@ const bundles = [
330
331
/******* React Is *******/
332
{
351
- label: 'react-is',
333
bundleTypes: [
334
NODE_DEV,
335
NODE_PROD,
@@ -365,7 +346,6 @@ const bundles = [
346
347
/******* React Debug Tools *******/
348
{
368
- label: 'react-debug-tools',
349
bundleTypes: [NODE_DEV, NODE_PROD],
350
moduleType: ISOMORPHIC,
351
entry: 'react-debug-tools',
@@ -375,7 +355,6 @@ const bundles = [
355
356
/******* React Cache (experimental) *******/
357
{
378
- label: 'react-cache',
358
bundleTypes: [
359
FB_WWW_DEV,
360
FB_WWW_PROD,
@@ -392,7 +371,6 @@ const bundles = [
371
372
/******* createComponentWithSubscriptions (experimental) *******/
373
{
395
- label: 'create-subscription',
374
bundleTypes: [NODE_DEV, NODE_PROD],
375
moduleType: ISOMORPHIC,
376
entry: 'create-subscription',
@@ -402,7 +380,6 @@ const bundles = [
380
381
/******* React Scheduler (experimental) *******/
382
{
405
- label: 'scheduler',
383
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
384
moduleType: ISOMORPHIC,
385
entry: 'scheduler',
@@ -412,7 +389,6 @@ const bundles = [
389
390
/******* Jest React (experimental) *******/
391
{
415
- label: 'jest-react',
392
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
393
moduleType: ISOMORPHIC,
394
entry: 'jest-react',
@@ -422,7 +398,6 @@ const bundles = [
398
399
/******* ESLint Plugin for Hooks (proposal) *******/
400
{
425
- label: 'eslint-plugin-react-hooks',
401
// TODO: it's awkward to create a bundle for this
402
// but if we don't, the package won't get copied.
403
// We also can't create just DEV bundle because
@@ -436,7 +411,6 @@ const bundles = [
411
},
412
413
{
439
- label: 'scheduler-tracing',
414
bundleTypes: [
415
FB_WWW_DEV,
416
FB_WWW_PROD,