Skip to content

module: open stat/readPackage to mutations#44537

Merged
nodejs-github-bot merged 3 commits intonodejs:mainfrom
arcanis:patch-1
Sep 18, 2022
Merged

module: open stat/readPackage to mutations#44537
nodejs-github-bot merged 3 commits intonodejs:mainfrom
arcanis:patch-1

Conversation

@arcanis
Copy link
Copy Markdown
Contributor

@arcanis arcanis commented Sep 6, 2022

While the CJS loader uses the fs module to perform most filesystem I/O, it uses two hidden internal primitives for speed: internalModuleStat, and packageJsonReader. Because internalModuleStat is destructured, it cannot be replaced. As a result, tools that experiment with virtual filesystem layers have to reimplement the whole CJS resolution stack. This is problematic because we want to experiment writing VFS with https://github.com/nodejs/single-executable.

This diff aims to provide a way for advanced tooling authors to avoid having to hijack the full resolution (which is much more invasive and dangerous than what this diff allows), while still respecting the wish for speed from Node (ie we're not suggesting to stop using the special internal primitives, but just to expose them the same way we already expose Module._findPaths or Module._resolveFilename).

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants