Patch FS for module resolution #40501
Labels
feature request
Issues that request new features to be added to Node.js.
fs
Issues and PRs related to the fs subsystem / file system.
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: