Skip to content

pnp: run all resolution test suites; fix the two bugs they surface#8

Open
ejc3 wants to merge 1 commit into
GGomez99:guyllian.gomez/yarn-pnpfrom
ejc3:pnp-test-coverage
Open

pnp: run all resolution test suites; fix the two bugs they surface#8
ejc3 wants to merge 1 commit into
GGomez99:guyllian.gomez/yarn-pnpfrom
ejc3:pnp-test-coverage

Conversation

@ejc3

@ejc3 ejc3 commented Jul 8, 2026

Copy link
Copy Markdown

Stacked on top of your Yarn PnP branch (microsoft#1966). Targets your branch so the diff is just these changes.

TestResolveUnqualified loads the full berry/esbuild test-expectations.json5 suites, ~18 cases — but a if si != 0 { continue } in the suite loop runs only the first suite, so 11 of the imported cases never execute: every fallback-pool, fallbackExclusionList, ignorePatternData, and global-package scenario.

Removing that one line surfaces two real bugs (both fixed here):

1. Fallback pool aliases

fallbackPool was parsed as [][2]string, which silently drops the [name, [aliasName, reference]] alias form Yarn emits — so a pooled alias never resolved (should allow the fallback pool to contain aliases failed). Parse it as []PackageDependency with the existing alias-aware parsePackageDependencies (the same shape packageDependencies already use), and return the matched entry directly from ResolveViaFallback. The now-unused parseStringPairs is removed.

2. ignorePatternData importers

An importer covered by the ignore pattern is not managed by PnP (e.g. a nested project with its own node_modules). ResolveToUnqualified returned "", and — because the PnP path replaces the classic ancestor walk entirely — such imports could not resolve at all (shouldn't go through PnP … covered by ignorePatternData failed).

Fix, matching the PnP spec's fallback-to-classic behavior:

  • ResolveToUnqualified returns the specifier unchanged for an ignored importer (the spec's passthrough).
  • loadModuleFromNearestNodeModulesDirectoryWorker runs the classic ancestor node_modules walk for an ignored importer instead of the PnP path.
  • New IsPathIgnored helper, reused by FindLocator and guarding the peer-dependency resolution path (so an ignored package dir keeps its classic node_modules + name fallback).

Result

All 5 suites (18 cases) pass. internal/module tests and the pnp* compiler baselines are unchanged. gofmt / go vet / the repo's golangci-lint are clean.

Context: this is the salvageable part of my own PnP attempt (microsoft#4568, now closed in favor of yours) — I hit the same design decisions you did and this is where I could actually add value. Happy to adjust anything to fit your direction, split it, or drop pieces.


Disclosure: authored with Claude Code (agent-assisted); I've read and understood the changes and will respond to review, per microsoft/typescript-go's CONTRIBUTING AI-assistance policy.

TestResolveUnqualified loaded the full berry/esbuild expectations file (5
suites, ~18 cases) but a `if si != 0 { continue }` ran only the first suite, so
11 of the imported cases never executed — including every fallback-pool,
fallbackExclusionList, ignorePatternData, and global-package scenario. Removing
the skip surfaced two real bugs, fixed here:

- Fallback pool aliases: `fallbackPool` was parsed as `[][2]string`, which drops
  the `[name, [aliasName, reference]]` alias form, so a pooled alias never
  resolved. Parse it as `[]PackageDependency` with the existing alias-aware
  parser (the same shape packageDependencies already use) and return the matched
  entry directly. Removes the now-unused parseStringPairs.

- ignorePatternData: an importer covered by the ignore pattern is not managed by
  PnP (e.g. a nested project with its own node_modules). ResolveToUnqualified now
  returns the specifier unchanged (the spec's passthrough) instead of "", and the
  module resolver runs the classic ancestor node_modules walk for an ignored
  importer instead of the PnP path — previously such imports could not resolve.
  Adds IsPathIgnored (reused by FindLocator and the peer-dependency path).

All five suites now pass; the internal/module tests and the pnp* compiler
baselines are unchanged.

Claude-Session: https://claude.ai/code/session_016TJMzkr87UoE2Rv3GZ5c6X

@GGomez99 GGomez99 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thank you very much for finding this issue!

Changes look good to me, but would you mind waiting for Fix alias resolution to be merged first?

It's handling the fallbackPool issue + aliases, and I received/reviewed it first 🙇

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.

2 participants