Skip to content

Rebase PnP support onto source phase imports (microsoft/TypeScript#63915) - #1

Closed
snovader wants to merge 8 commits into
mainfrom
snovader-source-phase
Closed

snovader wants to merge 8 commits into
mainfrom
snovader-source-phase

Conversation

@snovader

@snovader snovader commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Rebases the Yarn PnP commits from snovader onto upstream microsoft/TypeScript@2f9fd09a10 (microsoft#63915, source phase imports) so meteox can use import source for Wasm. The build from this branch, 7.1.0-dev.snovader.sha8c92e4a70c, is vendored in snovader/meteox#1242.

main is fast-forwarded to 2f9fd09, so this diff is exactly the rebased PnP commits. Don't merge this into main: land it by resetting snovader to this branch, and keep main as the upstream base.

Why this base

Rebasing onto v7.1-beta conflicted in 44 files, because upstream reworked the compiler hosts and module resolution after 2026-10-02. The import source commit itself has no later fixes upstream, and it conflicted in 7 files.

Conflicts

In the first commit, both sides were kept:

  • module/resolver.go: the PnP lookup for peer dependencies now falls back to upstream's new resolvePathForModule.
  • project/session.go: upstream's new session fields and the pnpApi field, plus both DefaultLibraryPath() and PnpApi().
  • diagnostics/diagnosticMessages.json: upstream's 18111–18115 messages plus the PnP messages; the generated files are regenerated.
  • ls/lsconv/converters_test.go: the PnP zip:// cases plus upstream's new untitled: encoding.
  • module/resolver_test.go: now an internal test package upstream, so the PnP stub and test are re-applied without the module. qualifier.

Adaptations

Upstream changes that git merged silently but that broke the PnP code:

  • Typed path prep bugfixes microsoft/TypeScript#64544 moved candidateDirectory: loadModuleFromSpecificNodeModulesDirectoryImpl now computes it, since the PnP resolver calls that function directly.
  • Typed path prep bugfixes microsoft/TypeScript#64544 changed the loop in tryGetModuleNameAsNodeModule: the PnP copy, tryGetModuleNameAsPnpPackage, gets the same change (currentParts and the new packageBaseRootIndex argument).
  • projectReferenceDtsFakingHost lost its host field upstream: it's back, so PnpApi() still delegates.
  • New hosts: api.Session, apiBuildSystem and project.SnapshotHost implement PnpApi(), delegating the same way their FS() does.
  • New NewCompilerHost call sites in upstream's tests pass the extra pnpApi argument.

"Adapt PnP support to current compiler APIs" became empty and is dropped. Its changes are in the first commit, which has to compile on the new base.

The last commit restores CRLF line endings in diagnosticMessages.json, which my conflict resolution had converted to LF. The vendored build is from 8c92e4a, the commit before it, and the build output is the same.

Tests

  • go build ./tsc/... and go vet ./tsc/...: clean
  • go test ./tsc/...: 67/67 packages passed, including pnp, module, modulespecifiers, compiler, project and api
  • npx hereby typescript:build --forRelease --setPrerelease dev.snovader.sha8c92e4a70c: succeeded
  • In meteox with this build: yarn typecheck reports 0 errors, the Node-native Vitest projects pass, and the sdks/typescript typecheck, tests and build pass

🤖 Generated with Claude Code

GGomez99 and others added 8 commits October 21, 2026 01:47
Ports the Yarn Plug'n'Play (PnP) support developed on
guyllian.gomez/yarn-pnp in typescript-go into this repo's layout,
adding a pnp resolver and vfs overlay so tsc/lsp can resolve modules
through .pnp.cjs/.pnp.data.json manifests without node_modules.

- internal/pnp: parses PnP manifests and resolves package/dependency
  locations
- internal/vfs/pnpvfs: read-through vfs.FS overlay that exposes
  zip-packed dependencies (zip:/path/to.zip/inner/path) as regular
  files
- module resolver, autoimport, and project/session wiring to plug the
  PnP resolver and vfs into the existing module resolution and LSP
  pipelines
- new compiler/fourslash test fixtures and baselines under
  tsc/testdata covering PnP resolution scenarios
- packages/vscode-typescript/src/client.ts: register the "zip" URI
  scheme in the LSP client's documentSelector so the extension
  attaches to files served from zip-packed PnP dependencies

Ported and squashed from the original branch history to reconcile
with divergent upstream refactors (module rename to
github.com/microsoft/TypeScript/tsc, auto-import infrastructure
rewrite) that landed in this repo's main before this port. Original
work also includes contributions from valentinmelusson (fix package
IDs for Yarn PnP submodule imports) and gun-yu (add pnp error
handling and test).

Co-Authored-By: valentinmelusson <valentin.melusson@datadoghq.com>
Co-Authored-By: gun-yu <163322737+gun-yu@users.noreply.github.com>
…ests

Co-Authored-By: ejc3 <ejc3@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Select the closest PnP manifest for each importer and project, cache scoped APIs, and reset the cache when manifests change. Watch each project’s manifest and preserve earlier snapshots during refresh.

Add regression tests for nested resolution, type roots, importability, manifest refresh, and root-workspace language service behavior.

Validation: full hereby validate, PnP race tests, both Meteox typechecks, and root-workspace LSP diagnostics and manifest watches.
Resolving the PnP diagnostics conflict during the rebase rewrote the
file with LF line endings, which showed the whole file as changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@snovader snovader closed this Oct 21, 2026
@snovader
snovader deleted the snovader-source-phase branch October 21, 2026 16:50
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