-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
pnpm version: 7.11.0
Code to reproduce the issue:
I have a workspace with main app A and a library B. A had react-query
as a dependency. B has react-query
as a peerDependency. For library B to be able to work, the dependency needs to be a singleton.
Even though they are using the same exact version, the dependency inside node_modules is being symlinked to two different places:
In App A is being symlinked to: node_modules/.pnpm/react-query@3.39.2_biqbaboplfbrettd7655fr4n2y/node_modules/react-query
In Library B is being symlinked to: node_modules/.pnpm/react-query@3.39.2/node_modules/react-query
I have tried pnpm up -r
and syncpack
. I have also tried to set an override for react-query: "^3.39.2"
.
None of this solved my problem.
Here are the two different listings for react-query in the pnpm lock file:
/react-query/3.39.2:
resolution: {integrity: sha512-F6hYDKyNgDQfQOuR1Rsp3VRzJnWHx6aRnnIZHMNGGgbL3SBgpZTDg8MQwmxOgpCAoqZJA+JSNCydF1xGJqKOCA==}
peerDependencies:
react: ^16.8.0 || ^17.0.0 || ^18.0.0
react-dom: '*'
react-native: '*'
peerDependenciesMeta:
react-dom:
optional: true
react-native:
optional: true
dependencies:
'@babel/runtime': 7.19.0
broadcast-channel: 3.7.0
match-sorter: 6.3.1
dev: true
/react-query/3.39.2_biqbaboplfbrettd7655fr4n2y:
resolution: {integrity: sha512-F6hYDKyNgDQfQOuR1Rsp3VRzJnWHx6aRnnIZHMNGGgbL3SBgpZTDg8MQwmxOgpCAoqZJA+JSNCydF1xGJqKOCA==}
peerDependencies:
react: ^16.8.0 || ^17.0.0 || ^18.0.0
react-dom: '*'
react-native: '*'
peerDependenciesMeta:
react-dom:
optional: true
react-native:
optional: true
dependencies:
'@babel/runtime': 7.19.0
broadcast-channel: 3.7.0
match-sorter: 6.3.1
react: 18.2.0
react-dom: 18.2.0_react@18.2.0
dev: false
The obvious difference seems to be dev
with true and false for each of these. No clue why they both exist though. Some help here would be greatly appreciated, since our monorepo breaks if we cannot use the same version for these packages.
Expected behavior:
The dependency should be reused, and the same dependency in both A and B should symlink to the same folder.
Actual behavior:
The dependency is duplicated, causing issues in the monorepo since it cannot be used as a singleton. This is especially problematic with react context related libraries, since this makes it impossible to extract functionality to a different library.
Additional information:
node -v
prints: v16.17.0- Windows, macOS, or Linux?: macOs