Skip to content

Commit

Permalink
fixup! module: disallow CJS <-> ESM edges in a cycle from require(esm)
Browse files Browse the repository at this point in the history
Co-authored-by: Geoffrey Booth <webadmin@geoffreybooth.com>
  • Loading branch information
joyeecheung and GeoffreyBooth authored Mar 31, 2024
1 parent 8ef78f9 commit 7540d1a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -2496,12 +2496,12 @@ object.
> Stability: 1 - Experimental
When trying to `require()` a [ES Module][] under `--experimental-require-module`,
a CommonJS -> ESM or ESM -> CommonJS edge participates in an immediate cycle.
a CommonJS to ESM or ESM to CommonJS edge participates in an immediate cycle.
This is not allowed because ES Modules cannot be evaluated while they are
already being evaluated.

To avoid the cycle, the `require()` call should not happen at the
top-level of either a ES Module (via `createRequire()`) or a ommonJS module, and
top-level of either a ES Module (via `createRequire()`) or a CommonJS module, and
should be done lazily in an inner function.

<a id="ERR_REQUIRE_ASYNC_MODULE"></a>
Expand Down

0 comments on commit 7540d1a

Please sign in to comment.