node/lib/internal/bootstrap
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
..
switches vm: support using the default loader to handle dynamic import() 2024-02-01 11:45:42 +00:00
web lib: define FormData and fetch etc. in the built-in snapshot 2024-01-31 17:44:23 +00:00
node.js src: add process.loadEnvFile and util.parseEnv 2024-01-23 18:46:26 +00:00
realm.js module: fix crash when built-in module export a default key 2024-01-19 08:42:07 +00:00
shadow_realm.js module: bootstrap module loaders in shadow realm 2023-11-13 22:09:47 +08:00