-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
preserveSymlinks doesn't work properly from root package #196
Comments
Created a repro repo here: https://github.com/bterlson/resolve-repro |
I'm not sure this is a bug. In your repro, the If you can find a repro where |
@octogonz not sure I follow, but considering the point of this module is to look up modules as Node does, and Node by default (with preserve symlinks off) will never resolve a module to a path which is symlinked, it seems clear this module is behaving incorrectly? |
@octogonz in the “preserve symlinks” case - which node used to do by default - resolve is correct. However, in the “don’t preserve symlinks” case, which is now node’s default as well as will be resolve’s default in v2, it doesn’t seem to be working here (where “working’ is mostly defined as “whatever node does”). I suspect the reasons this hasn't been reported before include that resolve's |
Hmmm... If the aim is to mimic the return value of the
Symlinks are used heavily in installations done by PNPM and also Rush, though. By now most tools support that, and rely on the If we fix this "bug", it might be a good idea to release it as SemVer MINOR (or MAJOR?), since it could theoretically break tools that might have relied on the current behavior somehow. |
Unfortunately every bugfix could potentially break those who rely on the bug - @bterlson is well aware of #194 ;-) - but the alternative is to release every patch as a major, which isn't really sustainable. Releasing as a minor versus a patch would have no different effect; nobody pins to a minor anymore. Given that |
@octogonz thank you so much for finding usage examples! It does seem possible that depending on this symlinking behavior is rare if most tools only need to a valid node_modules folder for io and don't care about the precise path. I thought for a while about how this could break things (I owe it to past me heh) but the current path normalization behavior seems hard to rely on. That said, I still expect this issue to get a ton of traffic in a few months :-P FWIW, I hit this because rollup is sensitive to path normalization. Resolving the same library to different paths means different copies of the library in the bundle. Resolve (in the context of rollup-plugin-node-resolve) seems to do the right thing most of the time, so it's possible this has just gone unnoticed for a while. |
I feel like we... come very different worlds. Turns out the two libraries that I referenced use "dependencies": {
"@microsoft/api-extractor-model": "7.2.0",
"@microsoft/node-core-library": "3.13.0",
"@microsoft/ts-command-line": "4.2.6",
"@microsoft/tsdoc": "0.12.9",
"colors": "~1.2.1",
"lodash": "~4.17.5",
"resolve": "1.8.1",
"source-map": "~0.6.1",
"typescript": "~3.4.3"
}, |
Pinning dependencies in package.json to exact versions doesn't actually give you any guarantees; you need a lockfile for that, and it's been the best practice in node for many many years to use That said, I certainly don't want to break anyone - but this feels like it's worth shipping it as a bugfix and waiting to get feedback. |
I'll point out that a lockfile doesn't help new installs that happen after a regression occurs, but before the problem is found+fixed. And in this case (since But I suppose it also means releasing as PATCH is cool as far as these two examples go heheh. |
See #197. |
- Update transitive dependency resolve to 1.12.0 - Fixes issue with symlink resolution which required dedupe workaround - browserify/resolve#196 - Fixes Azure#3326
- Update transitive dependency resolve to 1.12.0 - Fixes issue with symlink resolution which required dedupe workaround - browserify/resolve#196 - Fixes Azure#3326
- Update transitive dependency resolve to 1.12.0 - Fixes issue with symlink resolution which required dedupe workaround - browserify/resolve#196 - Move buffer to full dependency of service-bus - Packages required for browser bundles should be full dependencies - Improves customer experience when generating bundles from our packages - Add dependencies buffer and process to event-hubs - Required to generate browser bundle - Fixes Azure#3326
- Update transitive dependency resolve to 1.12.0 - Fixes issue with symlink resolution which required dedupe workaround - browserify/resolve#196 - Move buffer to full dependency of service-bus - Packages required for browser bundles should be full dependencies - Improves customer experience when generating bundles from our packages - Add dependencies buffer and process to event-hubs - Required to generate browser bundle - Fixes Azure#3326
- Update transitive dependency resolve to 1.12.0 - Fixes issue with symlink resolution which required dedupe workaround - browserify/resolve#196 - Move buffer to full dependency of service-bus - Packages required for browser bundles should be full dependencies - Improves customer experience when generating bundles from our packages - Add dependencies buffer and process to event-hubs - Required to generate browser bundle - Fixes Azure#3326
- Update transitive dependency resolve to 1.12.0 - Fixes issue with symlink resolution which required dedupe workaround - browserify/resolve#196 - Depends on rollup-plugin-commonjs@10.0.2 - Supports preserveSymlinks:false - rollup/rollup-plugin-commonjs#400 - Move buffer to full dependency of service-bus - Packages required for browser bundles should be full dependencies - Improves customer experience when generating bundles from our packages - Add dependencies buffer and process to event-hubs - Required to generate browser bundle - Fixes Azure#3326
Consider a library
lib
with the following file structure:In other words, a dependency exists from the root library to
buffer
which is symlinked into a separate folder (similar to how pnpm works).In this case,
resolve
doesn't seem to be mapping the symlinked paths to real paths properly.Repro Steps
resolve
and observe thatresolve('buffer/')
returns the symlinked path (root/mylib/node_modules/buffer
) instead of the real path (root/common/node_modules/buffer
).The text was updated successfully, but these errors were encountered: