-
Notifications
You must be signed in to change notification settings - Fork 191
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
[Feature Request]: Support resolve the modules with hard-links #410
Comments
Yea, sonds good, do you want to send a PR, also is it possible to enable it by default, i.e. |
Sure! I'm glad to send a PR. But actually, I'm not 100% sure about the correctness. Since it will make the compilation unstable(depends on the order of the requests). |
@colinaaa I think we have the same issue in webpack, need to search |
webpack-contrib/css-loader#1507, I think related |
@colinaaa As far as I know, pnpm created multiple hardlinks because it needs to ensure the accuracy of the peer dependencies. In your example, lodash should have no peer. Maybe you should check if In addition, simple cache should not solve the problem. And it will also destroy the accuracy of peerDependencies. If the
|
What problem does this feature solve?
pnpm creates hard links from the global store to the project's node_modules folders.
For example, imagine you have the following directory structure:
packages/a
andpackages/b
have the same version oflodash
as a dependency. But they are different symlink that points to different files.Since two
lodash/lodash.js
points to different files, bothrspack
(oroxc
internally) andwebpack
(orenhanced-resolve
internally) treat the two files as unrelated. So at build time, two copies oflodash
code will be packaged in the output bundle, even if their content is the same.However, it can be found that in the file system, the two
lodash.js
point exactly to the same inode node. Which means they are the same file in physical storage.To solve the problem, we created an
enhanced-resolve
plugin to cache the request:And it works as expected in
webpack
, the duplicated modules have been eliminated.So I wonder if this could be added to
enhanced-resolve
(just like thesymlinks
options).Related issue: web-infra-dev/rspack#5912
The text was updated successfully, but these errors were encountered: