Skip to content

Commit

Permalink
Match bundle.name and match upper case entry points (#24346)
Browse files Browse the repository at this point in the history
Fix matching in the build script.

It's possible to provide a custom bundle name in the case we build deep
imports. We should match those names as a convenience.

The script also calls toLowerCase on requested names but some entries have
upper case now.
  • Loading branch information
sebmarkbage authored and rickhanlonii committed Apr 19, 2022
1 parent 08e7723 commit 9f2e44e
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions scripts/rollup/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,21 @@ function shouldSkipBundle(bundle, bundleType) {
}
}
if (requestedBundleNames.length > 0) {
// 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.
const entryLowerCase = bundle.entry.toLowerCase() + '/index.js';
const isAskingForDifferentNames = requestedBundleNames.every(
// 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
requestedName => {
const matchEntry = entryLowerCase.indexOf(requestedName) !== -1;
if (!bundle.name) {
return !matchEntry;
}
const matchName =
bundle.name.toLowerCase().indexOf(requestedName) !== -1;
return !matchEntry && !matchName;
}
);
if (isAskingForDifferentNames) {
return true;
Expand Down

0 comments on commit 9f2e44e

Please sign in to comment.