node/lib/internal/process
Joyee Cheung b19525a33c
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: https://github.com/nodejs/node/pull/60278
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
2025-10-23 13:42:23 +00:00
..
execution.js module: remove experimental warning from type stripping 2025-06-11 10:12:04 +00:00
finalization.js lib: fix typos 2024-09-25 14:35:18 +00:00
per_thread.js process: fix default env for process.execve 2025-10-01 12:47:07 +00:00
permission.js src,permission: add --allow-inspector ability 2025-09-11 20:10:02 +00:00
pre_execution.js module: refactor and clarify async loader hook customizations 2025-10-23 13:42:23 +00:00
promises.js process: fix wrong asyncContext under unhandled-rejections=strict 2025-10-04 02:12:19 +00:00
report.js src: add cli option to preserve env vars on dr 2024-11-08 17:49:43 +00:00
signal.js errors: improve hideStackFrames 2023-11-11 16:25:08 +00:00
task_queues.js lib: remove redundant destroyHook checks 2025-10-08 12:11:43 +00:00
warning.js lib: prefer logical assignment 2024-10-09 06:42:16 +00:00
worker_thread_only.js lib: enforce ASCII order in error code imports 2024-04-23 17:05:38 +00:00