From 1987cb80ac1434d0c66ed9e64dd966f3e502941c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Markb=C3=A5ge?= Date: Mon, 11 Apr 2022 21:01:48 -0400 Subject: [PATCH] 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. --- scripts/rollup/build.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index c42edbe7eea64..52c0b7dc9fe29 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -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;