node/lib/internal/process
Joyee Cheung ad0bcb9c02
vm: support using the default loader to handle dynamic import()
This patch adds support for using
`vm.constants.USE_MAIN_CONTEXT_DEFAULT_LOADER` as
`importModuleDynamically` in all APIs that take the option
except `vm.SourceTextModule`. This allows users to have a shortcut
to support dynamic import() in the compiled code without missing
the compilation cache if they don't need customization of the
loading process. We emit an experimental warning when the
`import()` is actually handled by the default loader through
this option instead of requiring `--experimental-vm-modules`.

In addition this refactors the documentation for
`importModuleDynamically` and adds a dedicated section for it
with examples.

`vm.SourceTextModule` is not supported in this patch because
it needs additional refactoring to handle `initializeImportMeta`,
which can be done in a follow-up.

PR-URL: https://github.com/nodejs/node/pull/51244
Fixes: https://github.com/nodejs/node/issues/51154
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2024-02-01 11:45:42 +00:00
..
esm_loader.js module: remove useCustomLoadersIfPresent flag 2023-11-13 22:09:32 +08:00
execution.js esm: detect ESM syntax in ambiguous JavaScript 2023-10-20 15:44:56 +00:00
per_thread.js src: add process.loadEnvFile and util.parseEnv 2024-01-23 18:46:26 +00:00
permission.js permission: handle fs path traversal 2023-06-20 17:31:47 -03:00
policy.js policy: disable process.binding() when enabled 2023-08-09 14:29:06 -03:00
pre_execution.js vm: support using the default loader to handle dynamic import() 2024-02-01 11:45:42 +00:00
promises.js lib: add trailing commas in internal/process 2023-02-18 18:56:43 +01:00
report.js permission: v8.writeHeapSnapshot and process.report 2023-07-04 13:12:48 +00:00
signal.js errors: improve hideStackFrames 2023-11-11 16:25:08 +00:00
task_queues.js lib: add trailing commas in internal/process 2023-02-18 18:56:43 +01:00
warning.js src: add --disable-warning option 2023-11-21 20:30:02 +00:00
worker_thread_only.js lib: add trailing commas in internal/process 2023-02-18 18:56:43 +01:00