Skip to content

Commit

Permalink
Use Manual "name" for publicIds, Remove source bundles from Unique Ke…
Browse files Browse the repository at this point in the history
…ys (#9298)

Co-authored-by: mattcompiles <[email protected]>
  • Loading branch information
AGawrys and mattcompiles authored Oct 18, 2023
1 parent 47cf0e1 commit bc5c715
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 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.uniqueKey != null
? idealBundle.uniqueKey
: [...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 @@ -619,6 +622,7 @@ function createIdealGraph(
manualBundleToInternalizedAsset.get(bundleId),
).push(childAsset);
bundle.manualSharedBundle = manualSharedObject.name;
bundle.uniqueKey = manualSharedObject.name + childAsset.type;
}
} else {
bundle = nullthrows(bundleGraph.getNode(bundleId));
Expand Down Expand Up @@ -657,6 +661,7 @@ function createIdealGraph(
manualSharedMap.set(manualSharedBundleKey, bundleId);
}
bundle.manualSharedBundle = manualSharedObject.name;
bundle.uniqueKey = manualSharedObject.name + childAsset.type;
}
}

Expand Down Expand Up @@ -766,6 +771,7 @@ function createIdealGraph(
manualSharedMap.set(manualSharedBundleKey, bundleId);
}
bundle.manualSharedBundle = manualSharedObject.name;
bundle.uniqueKey = manualSharedObject.name + childAsset.type;
}
} else {
bundle = bundleGraph.getNode(bundleId);
Expand Down Expand Up @@ -795,6 +801,7 @@ function createIdealGraph(
manualSharedMap.set(manualSharedBundleKey, bundleId);
}
bundle.manualSharedBundle = manualSharedObject.name;
bundle.uniqueKey = manualSharedObject.name + childAsset.type;
}

bundles.set(childAsset.id, bundleId);
Expand Down Expand Up @@ -1239,6 +1246,7 @@ function createIdealGraph(
invariant(firstSourceBundle !== 'root');

bundle = createBundle({
uniqueKey: manualSharedObject.name + firstSourceBundle.type,
target: firstSourceBundle.target,
type: firstSourceBundle.type,
env: firstSourceBundle.env,
Expand Down Expand Up @@ -1443,6 +1451,7 @@ function createIdealGraph(

for (let i = 1; i < [...remainderMap.keys()].length; i++) {
let bundle = createBundle({
uniqueKey: manualSharedObject.name + firstSourceBundle.type + i,
target: firstSourceBundle.target,
type: firstSourceBundle.type,
env: firstSourceBundle.env,
Expand Down Expand Up @@ -1937,6 +1946,15 @@ async function loadBundlerConfig(
});
}

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

validateSchema.diagnostic(
CONFIG_SCHEMA,
{
Expand Down

0 comments on commit bc5c715

Please sign in to comment.