-
Notifications
You must be signed in to change notification settings - Fork 29.1k
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
Patch FS for module resolution #40501
Comments
If I monkeypatch The crux of the matter is that -- unlike most other tools -- Node.js and its ecosystem assign essential behavior to symlinks. So some other mechanism (like in-process patching) is need for transparent file management. FWIW, in-process FS patching is not unique, if this particular reason is. See https://docs.oracle.com/javase/8/docs/technotes/guides/io/fsp/filesystemprovider.html |
Similar to #33423 |
Indeed. Closing this in favor. |
Is your feature request related to a problem? Please describe.
I am customizing module/package.json location, necessary for good interop with Bazel build tool. Namely, I need to transparently customize file locations.
I cannot use symlinks because they change Node.js module resolution algorithm. (I cannot use preserve symlinks, because then hoisting becomes much more difficult, or at least compared to https://nodejs.org/api/modules.html#modules_package_manager_tips.)
I cannot use hardlinks because they may not be on the same file system.
Describe the solution you'd like
Monkeypatch the fs module (or
process.binding('fs')
), the same approach taken by npm's former tink project https://github.com/npm/tinkHowever, cjs/loader makes that impossible with code like
Then internalModuleStat is impossible to monkey patch.
I'd like some way of monkeypatching that. Tink is dead, but I assume it had some plan.
Even if that code were
Describe alternatives you've considered
Reimplement the node module algorithm and override at at different level like
Module._load
. This seems very complicated, involves package.json parsing, etc. Plus I'd need to repeat with other tools in the ecosystem.I could LD_PRELOAD inject glibc, but I'd have to do that for each platform.
The text was updated successfully, but these errors were encountered: