Skip to content

fix(nm): prefer direct dependency binaries#7216

Open
ychampion wants to merge 1 commit into
yarnpkg:masterfrom
ychampion:fix-direct-bin-precedence
Open

fix(nm): prefer direct dependency binaries#7216
ychampion wants to merge 1 commit into
yarnpkg:masterfrom
ychampion:fix-direct-bin-precedence

Conversation

@ychampion

Copy link
Copy Markdown

What's the problem this PR addresses?

Closes #7215.

With the node-modules linker, packages that export the same binary currently overwrite each other in traversal order. A transitive alias can therefore replace a direct dependency binary, as in the TypeScript 6/7 setup where .bin/tsc points to @typescript/old.

How did you fix it?

Bin collection now keeps the first target for a name, preserving the direct dependency encountered before its transitive dependency.

The regression uses aliased fixture packages and checks both the persisted root bin target and the generated .bin executable.

Validation

  • corepack yarn build:cli
  • corepack yarn workspace acceptance-tests test:integration --runTestsByPath "$PWD/packages/acceptance-tests/pkg-tests-specs/sources/node-modules.test.ts" --runInBand (63 passed, 2 platform-specific skipped)
  • corepack yarn test:lint
  • corepack yarn typecheck:all
  • corepack yarn constraints
  • corepack yarn version check

Checklist

  • I have read the Contributing Guide.
  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

Constraint: Preserve stable traversal order while preventing transitive bin overwrites.
Confidence: high
Scope-risk: narrow
Tested: node-modules acceptance tests; yarn test:lint; yarn typecheck:all; yarn constraints; yarn version check
Not-tested: Windows-specific shim execution locally
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug?]: node_modules/.bin/tsc not linked to the correct package when ts7 and ts6 are installed using aliases

1 participant