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

[node-modules] Support reducing trees requiring multiple hoisting passes to a terminal result #2394

Merged
merged 17 commits into from
Feb 5, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Shorrten hoistedFrom
  • Loading branch information
larixer committed Jan 21, 2021
commit d07894658a29b9cf3d5c3f38857bd979b2250e61
7 changes: 5 additions & 2 deletions packages/yarnpkg-pnpify/sources/hoist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,20 +496,23 @@ const hoistGraph = (tree: HoisterWorkTree, rootNodePath: Array<HoisterWorkTree>,
parentNode.hoistedDependencies.set(node.name, node);
parentNode.reasons.delete(node.name);
const hoistedNode = rootNode.dependencies.get(node.name);
let hoistedFrom: string | null = null;
if (options.debugLevel >= DebugLevel.REASONS)
hoistedFrom = [``].concat(Array.from(locatorPath).slice(rootNodePathLocators.size).concat([parentNode.locator]).map(x => prettyPrintLocator(x))).join(`→`);
// Add hoisted node to root node, in case it is not already there
if (!hoistedNode) {
// Avoid adding other version of root node to itself
if (rootNode.ident !== node.ident) {
rootNode.dependencies.set(node.name, node);
if (options.debugLevel >= DebugLevel.REASONS)
node.hoistedFrom.push(Array.from(locatorPath).concat([parentNode.locator]).map(x => prettyPrintLocator(x)).join(`→`));
node.hoistedFrom.push(hoistedFrom!);
newNodes.add(node);
}
} else {
for (const reference of node.references) {
hoistedNode.references.add(reference);
if (options.debugLevel >= DebugLevel.REASONS) {
hoistedNode.hoistedFrom.push(Array.from(locatorPath).concat([parentNode.locator]).map(x => prettyPrintLocator(x)).join(`→`));
hoistedNode.hoistedFrom.push(hoistedFrom!);
}
}
}
Expand Down