Skip to content

Commit

Permalink
Skip on missing parent asset for manual shared bundles (#9538)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikola-3 committed Feb 23, 2024
1 parent 0560499 commit ac43c39
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/bundlers/default/src/DefaultBundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ export default (new Bundler({
return loadBundlerConfig(config, options, logger);
},

bundle({bundleGraph, config}) {
bundle({bundleGraph, config, logger}) {
let targetMap = getEntryByTarget(bundleGraph); // Organize entries by target output folder/ distDir
let graphs = [];
for (let entries of targetMap.values()) {
// Create separate bundleGraphs per distDir
graphs.push(createIdealGraph(bundleGraph, config, entries));
graphs.push(createIdealGraph(bundleGraph, config, entries, logger));
}
for (let g of graphs) {
decorateLegacyGraph(g, bundleGraph); //mutate original graph
Expand Down Expand Up @@ -365,6 +365,7 @@ function createIdealGraph(
assetGraph: MutableBundleGraph,
config: ResolvedBundlerConfig,
entries: Map<Asset, Dependency>,
logger: PluginLogger,
): IdealGraph {
// Asset to the bundle and group it's an entry of
let bundleRoots: Map<BundleRoot, [NodeId, NodeId]> = new Map();
Expand Down Expand Up @@ -459,10 +460,13 @@ function createIdealGraph(

// Process in reverse order so earlier configs take precedence
for (let c of config.manualSharedBundles.reverse()) {
invariant(
c.root == null || configToParentAsset.has(c),
'Invalid manual shared bundle. Could not find parent asset.',
);
if (c.root != null && !configToParentAsset.has(c)) {
logger.warn({
origin: '@parcel/bundler-default',
message: `Manual shared bundle "${c.name}" skipped, no root asset found`,
});
continue;
}

let parentAsset = configToParentAsset.get(c);
let assetRegexes = c.assets.map(glob => globToRegex(glob));
Expand Down

0 comments on commit ac43c39

Please sign in to comment.