module: refactor and clarify async loader hook customizations · nodejs/node@67bfe86 · GitHub
Skip to content

Commit 67bfe86

Browse files
joyeecheungaduh95
authored andcommitted
module: refactor and clarify async loader hook customizations
- This updates the comments that assume loader hooks must be async - Differentiate the sync/async loader hook paths in naming `#customizations` is now `#asyncLoaderHooks` to make it clear it's from the async APIs. - Differentiate the paths running on the loader hook thread (affects the loading of async other loader hooks and are async) v.s. paths on the main thread calling out to code on the loader hook thread (do not handle loading of other async loader hooks, and can be sync by blocking). - `Hooks` is now `AsyncLoaderHooksOnLoaderHookWorker` - `CustomizedModuleLoader` is now `AsyncLoaderHooksProxiedToLoaderHookWorker` and moved into `lib/internal/modules/esm/hooks.js` as it implements the same interface as `AsyncLoaderHooksOnLoaderHookWorker` - `HooksProxy` is now `AsyncLoaderHookWorker` - Adjust the JSDoc accordingly - Clarify the "loader worker" as the "async loader hook worker" i.e. when there's no _async_ loader hook registered, there won't be this worker, to avoid the misconception that this worker is spawned unconditionally. - The code run on the loader hook worker to process `--experimental-loader` is moved into `lib/internal/modules/esm/worker.js` for clarity. - The initialization configuration `forceDefaultLoader` is split into `shouldSpawnLoaderHookWorker` and `shouldPreloadModules` as those can be separate. - `--experimental-vm-modules` is now processed during pre-execution and no longer part of the initialization of the built-in ESM loader, as it only exposes the vm APIs of ESM, and is unrelated to built-in ESM loading. PR-URL: #60278 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
1 parent 83a7252 commit 67bfe86

9 files changed

Lines changed: 355 additions & 309 deletions

File tree

lib/internal/main/worker_thread.js

Lines changed: 12 additions & 10 deletions

lib/internal/modules/esm/hooks.js

Lines changed: 137 additions & 11 deletions

0 commit comments

Comments
 (0)