Skip to content

module: initialize hook returns load, resolve

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.

TODO:

  • Obtain consent / consensus to explore this api.
  • Write tests.

Fixes: #50042 (closed)

Merge request reports

Loading