Skip to content

Commit

Permalink
module: initialize hook returns load, resolve
Browse files Browse the repository at this point in the history
This commit allows the `initialize()` hook to optionally return an
object having the `resolve()` and `load()` hooks as properties.
This allows state passed into `initialize()` to be shared with the
`resolve()` and `load()` hooks either via closure or class
instance.

In addition to developer ergonomics, supporting this model will
make it easier to write tests against a loader module. The
existing design forces state to be shared at the module level
which puts the burden of invalidating the ESM module cache
on anyone hoping to write isolated tests against a loader
module.

Fixes: nodejs#50042
  • Loading branch information
ggoodman committed Oct 24, 2023
1 parent 52fcf14 commit 9c09c98
Showing 1 changed file with 171 additions and 97 deletions.
Loading

0 comments on commit 9c09c98

Please sign in to comment.