Skip to content

Yarn-pnp: Attach to session and hoist filesystem overrides#5

Merged
GGomez99 merged 1 commit into
GGomez99:guyllian.gomez/yarn-pnpfrom
hegrec:fix_yarn_2
Apr 16, 2026
Merged

Yarn-pnp: Attach to session and hoist filesystem overrides#5
GGomez99 merged 1 commit into
GGomez99:guyllian.gomez/yarn-pnpfrom
hegrec:fix_yarn_2

Conversation

@hegrec

@hegrec hegrec commented Apr 14, 2026

Copy link
Copy Markdown

Overview

This diff removes some of the intermediary filesystem overrides and hoists those to the Go entrypoints for simplicity. We still have to plumb the pnpApi down so that it can be reached during module resolution. This is now done by attaching pnpApi to "session" instead of arbitarily passing it as an argument in various places, except in the boundary cases where session is not passed further, where we then pass the pnpApi itself from the session.

In general this should simplify the amount of touch points yarn pnp has with typescript-go, reducing merge conflicts or breakages.

Additionally, the reuse of entrypoint pnpApi initializations and removal of extra calls to "pnp.InitPnpApi" fixes a panic with the following stack trace when running the typescript-go binary in --api mode:

panic: CallbackFS: readFile called before connection set

goroutine 1 [running]:
github.com/microsoft/typescript-go/internal/api.(*callbackFS).ReadFile(0x1b098cc92a40, {0x1b098733f4f0, 0x42})
        /Users/guyllian.gomez/dev/typescript-go/internal/api/callbackfs.go:108 +0x150
github.com/microsoft/typescript-go/internal/pnp.parseManifestFromPath({0x10213a340, 0x1b098cc92a40}, {0x16f1466ef, 0x33})
        /Users/guyllian.gomez/dev/typescript-go/internal/pnp/manifestparser.go:83 +0x68
github.com/microsoft/typescript-go/internal/pnp.(*PnpApi).findClosestPnpManifest(0x1b098730f140)
        /Users/guyllian.gomez/dev/typescript-go/internal/pnp/pnpapi.go:163 +0xfc
github.com/microsoft/typescript-go/internal/pnp.InitPnpApi({0x10213a340, 0x1b098cc92a40}, {0x16f1466ef, 0x33})
        /Users/guyllian.gomez/dev/typescript-go/internal/pnp/pnp.go:12 +0x78
github.com/microsoft/typescript-go/internal/project.NewSnapshot(_, _, _, _, _, {{{0x0, 0x4, 0x4, {0x1015a5fb8, 0x1}, ...}, ...}, ...}, ...)
        /Users/guyllian.gomez/dev/typescript-go/internal/project/snapshot.go:67 +0x44
github.com/microsoft/typescript-go/internal/project.NewSession(0x1b09894abd00)
        /Users/guyllian.gomez/dev/typescript-go/internal/project/session.go:188 +0x38c
github.com/microsoft/typescript-go/internal/api.(*StdioServer).Run(0x1b09894abe08, {0x1021328b8, 0x1b0986426a80})
        /Users/guyllian.gomez/dev/typescript-go/internal/api/server.go:85 +0x350
main.runAPI({0x1b098629e200, 0x4, 0x4})
        /Users/guyllian.gomez/dev/typescript-go/cmd/tsgo/api.go:54 +0x30c
main.runMain()
        /Users/guyllian.gomez/dev/typescript-go/cmd/tsgo/main.go:20 +0xa4
main.main()
        /Users/guyllian.gomez/dev/typescript-go/cmd/tsgo/main.go:10 +0x1c

Test Plan

Build binary locally and test in API mode as well as with the binary powering tsserver in VS Code.

@hegrec hegrec force-pushed the fix_yarn_2 branch 2 times, most recently from ebe9dc0 to e916a45 Compare April 15, 2026 10:47
@hegrec hegrec changed the title Yarn pnp: Plumb yarn pnp through a few more layers Yarn-pnp: Attach to session and hoist filesystem overrides Apr 15, 2026
Comment thread internal/project/autoimport.go
Comment thread internal/project/compilerhost.go Outdated
Comment thread internal/project/snapshot.go Outdated
Comment thread internal/project/session.go Outdated
@GGomez99 GGomez99 merged commit 06c8485 into GGomez99:guyllian.gomez/yarn-pnp Apr 16, 2026
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