Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip on missing parent asset for manual shared bundles #9538

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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