Skip to content

Commit

Permalink
module: refator ESM loader for adding future synchronous hooks
Browse files Browse the repository at this point in the history
This lays the foundation for supporting synchronous hooks proposed
in nodejs/loaders#198 for ESM.

- Corrects and adds several JSDoc comments for internal functions
  of the ESM loader, as well as explaining how require() for
  import CJS work in the special resolve/load paths. This doesn't
  consolidate it with import in require(esm) yet due to caching
  differences, which is left as a TODO.
- The moduleProvider passed into ModuleJob is replaced as
  moduleOrModulePromise, we call the translators directly in the
  ESM loader and verify it right after loading for clarity.
- Reuse a few refactored out helpers for require(esm) in
  getModuleJobForRequire().

PR-URL: nodejs#54769
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Stephen Belanger <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
joyeecheung authored Sep 17, 2024
1 parent 7014e50 commit 3ac5b49
Show file tree
Hide file tree
Showing 3 changed files with 264 additions and 156 deletions.
Loading

0 comments on commit 3ac5b49

Please sign in to comment.