Skip to content

Fixing --preserve-symlinks. Enhancing node to exploit. #10107

@ghost

Description

A working prototype that enables using symlinks to machine level module stores, so modules no longer need to be physically copied and duplicated wherever they're used on a given machine. This is accomplished by:

  1. Effectively, setting __dirname of the "main" entry module to the preserved path passed on the command line, or if it's a file-symlink, using its target path. This is intended to start the program off in the right symbolic path space, to address tooling problems resulting from the current behavior, where __dirname is always the fs.realpath().
  2. For all other require()d modules, always using the preserved path of its directory location as its __dirname, but always using its realpath as the module cache key. This resolves the memory bloat and add-on crashing problems while still letting resolution happen within the symbolic path space.
  3. When building the list of search paths to be used for resolution, by interleaving adjacent somemod+node_modules directory paths after the subordinate somemod/node_modules, the directory structure dictating dependency version resolution can still be bound and specific to a given top-level /node_modules, but can now be completely decoupled from the physical directories of the modules involved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.moduleIssues and PRs related to the module subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions