vm: reject in importModuleDynamically without --experimental-vm-modules

Users cannot access any API that can be used to return a module or
module namespace in this callback without --experimental-vm-modules
anyway, so this would eventually lead to a rejection. This patch
rejects in this case with our own error message and use a constant
host-defined option for the rejection, so that scripts with the
same source can still be compiled using the compilation cache
if no `import()` is actually called in the script.

PR-URL: https://github.com/nodejs/node/pull/50137
Refs: https://github.com/nodejs/node/issues/35375
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
Joyee Cheung authored and Node.js GitHub Bot committed 2023-10-17 13:24:54 +00:00
1 parent a3407b4ee8
commit c2d79208d6
7 files changed
+81 -7

No files matched your search

+6
View File
@@ -2981,6 +2981,12 @@ An attempt was made to use something that was already closed.
While using the Performance Timing API (`perf_hooks`), no valid performance
entry types are found.
<a id="ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG"></a>
### `ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG`
A dynamic import callback was invoked without `--experimental-vm-modules`.
<a id="ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING"></a>
### `ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`