Match bundle.name and match upper case entry points (#24346)
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.
Sebastian Markbåge committed
Apr 11, 2022 at 21:01 UTC
80170a0681def183f8f3153425f1086d3d383922
1 file changed
+14
-6
scripts/rollup/build.js
+14
-6
@@ -438,13 +438,21 @@ function shouldSkipBundle(bundle, bundleType) {
438
}
439
}
440
if (requestedBundleNames.length > 0) {
441
+ // If the name ends with `something/index` we only match if the
442
+ // entry ends in something. Such as `react-dom/index` only matches
443
+ // `react-dom` but not `react-dom/server`. Everything else is fuzzy
444
+ // search.
445
+ const entryLowerCase = bundle.entry.toLowerCase() + '/index.js';
446
const isAskingForDifferentNames = requestedBundleNames.every(
442
- // If the name ends with `something/index` we only match if the
443
- // entry ends in something. Such as `react-dom/index` only matches
444
- // `react-dom` but not `react-dom/server`. Everything else is fuzzy
445
- // search.
446
- requestedName =>
447
- (bundle.entry + '/index.js').indexOf(requestedName) === -1
447
+ requestedName => {
448
+ const matchEntry = entryLowerCase.indexOf(requestedName) !== -1;
449
+ if (!bundle.name) {
450
+ return !matchEntry;
451
+ }
452
+ const matchName =
453
+ bundle.name.toLowerCase().indexOf(requestedName) !== -1;
454
+ return !matchEntry && !matchName;
455
+ }
456
);
457
if (isAskingForDifferentNames) {
458
return true;