Skip to content

lib: lazyload fs to ease Electron's monkey-patching #58020

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

codebytere
Copy link
Member

Adjusts several uses of fs in ESM to make Electron's life a little easier as we monkey-patch FS to handle our custom archive formatting.

This pattern is used in several other areas of Node.js, so it shouldn't be too out of place. This allows us to reduce our patch surface a bit.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders
@nodejs-github-bot nodejs-github-bot added esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. labels Apr 25, 2025
Copy link

codecov bot commented Apr 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.28%. Comparing base (d12ee6e) to head (e366a6e).
Report is 20 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #58020      +/-   ##
==========================================
+ Coverage   90.26%   90.28%   +0.02%     
==========================================
  Files         630      630              
  Lines      186170   186157      -13     
  Branches    36478    36474       -4     
==========================================
+ Hits       168042   168069      +27     
+ Misses      10982    10972      -10     
+ Partials     7146     7116      -30     
Files with missing lines Coverage Δ
lib/internal/modules/esm/load.js 91.91% <100.00%> (-0.04%) ⬇️
lib/internal/modules/esm/resolve.js 96.17% <100.00%> (ø)
lib/internal/modules/esm/translators.js 91.57% <100.00%> (ø)

... and 34 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should do it, it goes against our goal to have (some of) Node.js internals being unaffected by userland mutation, ESM has always been on the list of "if it's affected by userland, we have a bug".
Maybe another solution would be to have some internal/fs module that all code modules would use, and Electron et al. could patch that single module, wdyt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run.
3 participants