diff options
Diffstat (limited to 'doc/api/vm.md')
-rw-r--r-- | doc/api/vm.md | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/doc/api/vm.md b/doc/api/vm.md index 6259b9b2ff..07923de585 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -167,10 +167,19 @@ const contextifiedSandbox = vm.createContext({ secret: 42 }); in stack traces produced by this `Module`. * `columnOffset` {integer} Specifies the column number offset that is displayed in stack traces produced by this `Module`. - * `initalizeImportMeta` {Function} Called during evaluation of this `Module` + * `initializeImportMeta` {Function} Called during evaluation of this `Module` to initialize the `import.meta`. This function has the signature `(meta, module)`, where `meta` is the `import.meta` object in the `Module`, and `module` is this `vm.SourceTextModule` object. + * `importModuleDynamically` {Function} Called during evaluation of this + module when `import()` is called. This function has the signature + `(specifier, module)` where `specifier` is the specifier passed to + `import()` and `module` is this `vm.SourceTextModule`. If this option is + not specified, calls to `import()` will reject with + [`ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`][]. This method can return a + [Module Namespace Object][], but returning a `vm.SourceTextModule` is + recommended in order to take advantage of error tracking, and to avoid + issues with namespaces that contain `then` function exports. Creates a new ES `Module` object. @@ -436,6 +445,15 @@ changes: The `cachedDataProduced` value will be set to either `true` or `false` depending on whether code cache data is produced successfully. This option is deprecated in favor of `script.createCachedData()`. + * `importModuleDynamically` {Function} Called during evaluation of this + module when `import()` is called. This function has the signature + `(specifier, module)` where `specifier` is the specifier passed to + `import()` and `module` is this `vm.SourceTextModule`. If this option is + not specified, calls to `import()` will reject with + [`ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`][]. This method can return a + [Module Namespace Object][], but returning a `vm.SourceTextModule` is + recommended in order to take advantage of error tracking, and to avoid + issues with namespaces that contain `then` function exports. Creating a new `vm.Script` object compiles `code` but does not run it. The compiled `vm.Script` can be run later multiple times. The `code` is not bound to @@ -945,6 +963,7 @@ associating it with the `sandbox` object is what this document refers to as "contextifying" the `sandbox`. [`Error`]: errors.html#errors_class_error +[`ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`]: errors.html#ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING [`URL`]: url.html#url_class_url [`eval()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval [`script.runInContext()`]: #vm_script_runincontext_contextifiedsandbox_options @@ -954,6 +973,7 @@ associating it with the `sandbox` object is what this document refers to as [`vm.runInContext()`]: #vm_vm_runincontext_code_contextifiedsandbox_options [`vm.runInThisContext()`]: #vm_vm_runinthiscontext_code_options [GetModuleNamespace]: https://tc39.github.io/ecma262/#sec-getmodulenamespace +[Module Namespace Object]: https://tc39.github.io/ecma262/#sec-module-namespace-exotic-objects [ECMAScript Module Loader]: esm.html#esm_ecmascript_modules [Evaluate() concrete method]: https://tc39.github.io/ecma262/#sec-moduleevaluation [HostResolveImportedModule]: https://tc39.github.io/ecma262/#sec-hostresolveimportedmodule |