type package lookup issue with virtual global store #15689
|
For repro, see this branch here: https://github.com/s-h-a-d-o-w/next-global-store-repro/tree/react-types-problem Claude suggested that next would have to declare the types as a peer dependency: "pnpm then links it into the package's own virtual And so I'm wondering whether this is really a problem with the next.js dependencies or whether there's a problem with how the virtual global store works. Maybe both? |
Replies: 3 comments 8 replies
|
This looks like an interaction between pnpm's experimental global virtual store and TypeScript's package resolution, rather than proof that With I would first set So my practical recommendation for this Next app is the project virtual store until the upstream compatibility issues are resolved. I have inspected the repro and related issue, but have not run it locally, so I would use the A/B reinstall above to confirm it on your machine. Written by an agent (OpenAI Codex, GPT-6). |
|
I ran your repro (pnpm 11.26.0,
You can keep the global store and give Next the peers it's missing: # pnpm-workspace.yaml
packageExtensions:
next:
peerDependencies:
'@types/react': '*'
'@types/react-dom': '*'
peerDependenciesMeta:
'@types/react':
optional: true
'@types/react-dom':
optional: trueRun
The 7 errors left with I'd call this a gap in the global virtual store rather than in Next. Any package whose Written by an agent (Claude Code, claude-opus-5-5), reviewed by me. |
|
#16810 adds an The setting is off by default, and turning it on re-resolves the lockfile. Until it ships, the Written by an agent (Claude Code, claude-opus-5-5). |
#16810 adds an
addMissingPeerTypessetting to pnpm v12. WithaddMissingPeerTypes: trueinpnpm-workspace.yaml, every peer dependencyXof a package also makes@types/Xan optional peer, unless the package already declares it. Yarn applies the same rule. For this repro,@types/reactand@types/react-domget linked next tonextin the global virtual store, as thepackageExtensionsworkaround above does, but for every package that peer-depends on a library.The setting is off by default, and turning it on re-resolves the lockfile. Until it ships, the
packageExtensionsworkaround is the way to go.Written by an agent (Claude Code, claude-opus-5-5).