deno
2cf425f8 - fix(ext/node): detect ESM/CJS circular require cycles

Commit
78 days ago
fix(ext/node): detect ESM/CJS circular require cycles Add ERR_REQUIRE_CYCLE_MODULE error when require() encounters an ESM module that is currently being loaded in a circular dependency with CJS. Previously, Deno would silently return partial/undefined exports for ESM modules in CJS require cycles. Node.js throws ERR_REQUIRE_CYCLE_MODULE in this case. The detection works at two levels: - Rust: track module IDs on the op_import_sync call stack to detect re-entrant evaluation - JS: check Module._cache for not-yet-loaded ESM modules (.mjs or package type "module") and throw before returning partial exports
Author
Committer
Parents
Loading