Skip to content

Commit

Permalink
make public Ids for manual shared Bundles their names and dont includ…
Browse files Browse the repository at this point in the history
…e source bundles for shared bundles unique keys
  • Loading branch information
AGawrys committed Oct 6, 2023
1 parent ce58970 commit 13318e8
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions packages/bundlers/default/src/DefaultBundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,14 @@ function decorateLegacyGraph(
idealBundle.sourceBundles.size > 0 &&
!idealBundle.mainEntryAsset
) {
let uniqueKey =
idealBundle.manualSharedBundle != null
? idealBundle.manualSharedBundle
: [...idealBundle.assets].map(asset => asset.id).join(',');

bundle = nullthrows(
bundleGraph.createBundle({
uniqueKey:
[...idealBundle.assets].map(asset => asset.id).join(',') +
[...idealBundle.sourceBundles].join(','),
uniqueKey,
needsStableName: idealBundle.needsStableName,
bundleBehavior: idealBundle.bundleBehavior,
type: idealBundle.type,
Expand Down Expand Up @@ -1420,7 +1423,7 @@ function createIdealGraph(
target: firstSourceBundle.target,
type: firstSourceBundle.type,
env: firstSourceBundle.env,
manualSharedBundle: manualSharedObject.name,
manualSharedBundle: manualSharedObject.name + i,
});
bundle.sourceBundles = manualBundle.sourceBundles;
bundle.internalizedAssets = manualBundle.internalizedAssets;
Expand Down Expand Up @@ -1911,6 +1914,17 @@ async function loadBundlerConfig(
});
}

if (modeConfig.unstable_manualSharedBundles) {
let nameArray = modeConfig.unstable_manualSharedBundles.map(a => a.name);
let nameSet = new Set(nameArray);
if (nameSet.size != nameArray.length) {
let err = new Error();
throw new Error(
`The name field must be unique for property unstable_manualSharedBundles`,
);
}
}

validateSchema.diagnostic(
CONFIG_SCHEMA,
{
Expand Down

0 comments on commit 13318e8

Please sign in to comment.