Skip to content

Fix empty exports for CommonJS modules imported after quibble() - #128

Merged
rosston merged 1 commit into
mainfrom
fix-cjs-import-after-quibble-111
Oct 12, 2026
Merged

rosston merged 1 commit into
mainfrom
fix-cjs-import-after-quibble-111

Conversation

@rosston

@rosston rosston commented Oct 12, 2026

Copy link
Copy Markdown
Member

Fixes #111

On Node 20.6-24.17 and 25.x, Node's ESM loader caches a not-yet-loaded Module for a CommonJS file, loads it through Module._load, and reads the exports off that cached object. doWithoutCache swapped the entry out for a fresh copy and put the empty one back, so import() returned {}.

Leave an unloaded cache entry in place and load it there. Already-loaded modules still get a fresh copy.

Fixes #111

On Node 20.6-24.17 and 25.x, Node's ESM loader caches a not-yet-loaded
Module for a CommonJS file, loads it through Module._load, and reads the
exports off that cached object. doWithoutCache swapped the entry out for
a fresh copy and put the empty one back, so import() returned {}.

Leave an unloaded cache entry in place and load it there. Already-loaded
modules still get a fresh copy.
@rosston rosston self-assigned this Oct 12, 2026
@rosston
rosston marked this pull request as ready for review October 12, 2026 14:58
@rosston
rosston merged commit e87445f into main Oct 12, 2026
18 checks passed
@rosston
rosston deleted the fix-cjs-import-after-quibble-111 branch October 12, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

exports are empty when ESM loader loads a cjs package which uses a quibbled module

1 participant