You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
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
The text was updated successfully, but these errors were encountered: