Skip to content

Commit

Permalink
Use Entry in yarn build ... Instead of Label (#14148)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
sebmarkbage authored Nov 8, 2018
1 parent 3ff2c7c commit 051272f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 33 deletions.
37 changes: 30 additions & 7 deletions scripts/rollup/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,30 @@ const {
RN_FB_PROFILING,
} = Bundles.bundleTypes;

const requestedBundleTypes = (argv.type || '')
.split(',')
.map(type => type.toUpperCase());
const requestedBundleNames = (argv._[0] || '')
.split(',')
.map(type => type.toLowerCase());
function parseRequestedNames(names, toCase) {
let result = [];
for (let i = 0; i < names.length; i++) {
let splitNames = names[i].split(',');
for (let j = 0; j < splitNames.length; j++) {
let name = splitNames[j].trim();
if (!name) {
continue;
}
if (toCase === 'uppercase') {
name = name.toUpperCase();
} else if (toCase === 'lowercase') {
name = name.toLowerCase();
}
result.push(name);
}
}
return result;
}

const requestedBundleTypes = argv.type
? parseRequestedNames([argv.type], 'uppercase')
: [];
const requestedBundleNames = parseRequestedNames(argv._, 'lowercase');
const forcePrettyOutput = argv.pretty;
const syncFBSourcePath = argv['sync-fbsource'];
const syncWWWPath = argv['sync-www'];
Expand Down Expand Up @@ -407,7 +425,12 @@ function shouldSkipBundle(bundle, bundleType) {
}
if (requestedBundleNames.length > 0) {
const isAskingForDifferentNames = requestedBundleNames.every(
requestedName => bundle.label.indexOf(requestedName) === -1
// If the name ends with `something/index` we only match if the
// entry ends in something. Such as `react-dom/index` only matches
// `react-dom` but not `react-dom/server`. Everything else is fuzzy
// search.
requestedName =>
(bundle.entry + '/index.js').indexOf(requestedName) === -1
);
if (isAskingForDifferentNames) {
return true;
Expand Down
26 changes: 0 additions & 26 deletions scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ const NON_FIBER_RENDERER = moduleTypes.NON_FIBER_RENDERER;
const bundles = [
/******* Isomorphic *******/
{
label: 'core',
bundleTypes: [
UMD_DEV,
UMD_PROD,
Expand All @@ -75,7 +74,6 @@ const bundles = [

/******* React DOM *******/
{
label: 'dom-client',
bundleTypes: [
UMD_DEV,
UMD_PROD,
Expand All @@ -95,7 +93,6 @@ const bundles = [

//******* Test Utils *******/
{
label: 'dom-test-utils',
moduleType: RENDERER_UTILS,
bundleTypes: [FB_WWW_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
entry: 'react-dom/test-utils',
Expand All @@ -105,7 +102,6 @@ const bundles = [

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

/******* React DOM Server *******/
{
label: 'dom-server-browser',
bundleTypes: [
UMD_DEV,
UMD_PROD,
Expand All @@ -138,7 +133,6 @@ const bundles = [
},

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

/******* React ART *******/
{
label: 'art',
bundleTypes: [
UMD_DEV,
UMD_PROD,
Expand All @@ -169,7 +162,6 @@ const bundles = [

/******* React Native *******/
{
label: 'native-fb',
bundleTypes: [RN_FB_DEV, RN_FB_PROD, RN_FB_PROFILING],
moduleType: RENDERER,
entry: 'react-native-renderer',
Expand All @@ -189,7 +181,6 @@ const bundles = [
},

{
label: 'native',
bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING],
moduleType: RENDERER,
entry: 'react-native-renderer',
Expand All @@ -210,7 +201,6 @@ const bundles = [

/******* React Native Fabric *******/
{
label: 'native-fabric-fb',
bundleTypes: [RN_FB_DEV, RN_FB_PROD, RN_FB_PROFILING],
moduleType: RENDERER,
entry: 'react-native-renderer/fabric',
Expand All @@ -231,7 +221,6 @@ const bundles = [
},

{
label: 'native-fabric',
bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING],
moduleType: RENDERER,
entry: 'react-native-renderer/fabric',
Expand All @@ -253,7 +242,6 @@ const bundles = [

/******* React Test Renderer *******/
{
label: 'test',
bundleTypes: [FB_WWW_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
moduleType: RENDERER,
entry: 'react-test-renderer',
Expand All @@ -262,7 +250,6 @@ const bundles = [
},

{
label: 'test-shallow',
bundleTypes: [FB_WWW_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
moduleType: NON_FIBER_RENDERER,
entry: 'react-test-renderer/shallow',
Expand All @@ -272,7 +259,6 @@ const bundles = [

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

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

/******* React Reconciler *******/
{
label: 'react-reconciler',
bundleTypes: [NODE_DEV, NODE_PROD],
moduleType: RECONCILER,
entry: 'react-reconciler',
Expand All @@ -328,7 +312,6 @@ const bundles = [

/******* React Persistent Reconciler *******/
{
label: 'react-reconciler-persistent',
bundleTypes: [NODE_DEV, NODE_PROD],
moduleType: RECONCILER,
entry: 'react-reconciler/persistent',
Expand All @@ -338,7 +321,6 @@ const bundles = [

/******* Reflection *******/
{
label: 'reconciler-reflection',
moduleType: RENDERER_UTILS,
bundleTypes: [NODE_DEV, NODE_PROD],
entry: 'react-reconciler/reflection',
Expand All @@ -348,7 +330,6 @@ const bundles = [

/******* React Is *******/
{
label: 'react-is',
bundleTypes: [
NODE_DEV,
NODE_PROD,
Expand All @@ -365,7 +346,6 @@ const bundles = [

/******* React Debug Tools *******/
{
label: 'react-debug-tools',
bundleTypes: [NODE_DEV, NODE_PROD],
moduleType: ISOMORPHIC,
entry: 'react-debug-tools',
Expand All @@ -375,7 +355,6 @@ const bundles = [

/******* React Cache (experimental) *******/
{
label: 'react-cache',
bundleTypes: [
FB_WWW_DEV,
FB_WWW_PROD,
Expand All @@ -392,7 +371,6 @@ const bundles = [

/******* createComponentWithSubscriptions (experimental) *******/
{
label: 'create-subscription',
bundleTypes: [NODE_DEV, NODE_PROD],
moduleType: ISOMORPHIC,
entry: 'create-subscription',
Expand All @@ -402,7 +380,6 @@ const bundles = [

/******* React Scheduler (experimental) *******/
{
label: 'scheduler',
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
moduleType: ISOMORPHIC,
entry: 'scheduler',
Expand All @@ -412,7 +389,6 @@ const bundles = [

/******* Jest React (experimental) *******/
{
label: 'jest-react',
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
moduleType: ISOMORPHIC,
entry: 'jest-react',
Expand All @@ -422,7 +398,6 @@ const bundles = [

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

{
label: 'scheduler-tracing',
bundleTypes: [
FB_WWW_DEV,
FB_WWW_PROD,
Expand Down

0 comments on commit 051272f

Please sign in to comment.