Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@types packages should be hoisted traditionally per package in monorepos when using typescript #6311

Closed
ilijaNL opened this issue Mar 29, 2023 · 1 comment
Milestone

Comments

@ilijaNL
Copy link

ilijaNL commented Mar 29, 2023

pnpm version:

8.0.0

Code to reproduce the issue:

https://github.com/ilijaNL/pnpm-monorepo-types-hoisting

pnpm install & cd react17 & pnpm tc:debug

Expected behavior:

All devDependencies or @types/* should be hoisted correctly per package/app

Actual behavior:

If some transient package has '*' version or no @types dependencies defined, the typescript compiler will use the global hoisted package from the root/node_modules/.pnpm/node_modules directory even if a monorepo package has the correct devDependency version defined.
This is problematic when having a monorepo with different major version (+types), for example having react 17 & react 18 apps.

The module trace resolution can be seen here for @types/react-dom which has a dependency to @types/react: "*":
https://github.com/ilijaNL/pnpm-monorepo-types-hoisting/blob/78ead3e37f9f27b78124b7e33a1747cd496a87ee/react17/log.txt#L1544

This is probably a major problem for a lot of monorepos when using different (major) versions of types.

Possibly related: #6053, #5176

A possible solution could be to create one level deeper directory in .pnpm?:

node_modules/.pnpm/packageA/<all packages>

Additional information:

node 18
MacOS

@ilijaNL ilijaNL changed the title @types packages should be hoisted traditionally per package in monorepos @types packages should be hoisted traditionally per package in monorepos when using typescript Mar 29, 2023
@zkochan
Copy link
Member

zkochan commented Mar 30, 2023

🚢 8.1.0

@zkochan zkochan closed this as completed Mar 30, 2023
@zkochan zkochan added this to the v8.1 milestone Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants