esm: merge and simplify loader hooks
Demo for reducing the number of hooks and allowing more delegation to the builtin hooks.
Downsides:
- Eagerly loads source for JSON, even when it's not used.
- If node thinks a module is CommonJS, it will currently not return the source from
getSource
. Since we now parse the CommonJS source for named exports, it would likely be fine if we'd return source fromload
anyhow but it's unclear how that would interact with userland hooks.
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines