Skip to content

Conversation

@joyeecheung
Copy link
Member

@joyeecheung joyeecheung commented Jan 26, 2026

Previously the resolve hook can be invoked twice from the synthetic module evaluation step of imported CJS in the extra module._load() call that's invoked on the resolved full path. Add an option to avoid it, since the resolution and loading has already been done before.

Fixes: #57125
Refs: #55808
Refs: #56241

@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. module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run. labels Jan 26, 2026
Previously the resolve hook can be invoked twice from the
synthetic module evaluation step of imported CJS in the extra
module._load() call that's invoked on the resolved full path.
Add an option to avoid it, since the resolution and loading
has already been done before.
@joyeecheung joyeecheung force-pushed the fix-resolve-import-cjs branch from c9c9137 to cc0b7cd Compare January 26, 2026 14:15
@joyeecheung joyeecheung changed the title module: do not invoke resolve hooks again for imported cjs module: do not invoke resolve hooks twice for imported cjs Jan 26, 2026
@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@JakobJingleheimer JakobJingleheimer left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov
Copy link

codecov bot commented Jan 26, 2026

Codecov Report

❌ Patch coverage is 85.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.77%. Comparing base (83893bb) to head (cc0b7cd).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/modules/esm/translators.js 70.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61529      +/-   ##
==========================================
- Coverage   89.78%   89.77%   -0.01%     
==========================================
  Files         672      672              
  Lines      203809   203818       +9     
  Branches    39183    39186       +3     
==========================================
- Hits       182980   182972       -8     
- Misses      13166    13174       +8     
- Partials     7663     7672       +9     
Files with missing lines Coverage Δ
lib/internal/modules/cjs/loader.js 98.35% <100.00%> (+0.18%) ⬆️
lib/internal/modules/esm/translators.js 92.75% <70.00%> (-0.23%) ⬇️

... and 28 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.

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. module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

require(esm) always feeds full filepaths to customization hooks but require.resolve doesn't

4 participants