diff --git a/doc/api/vm.md b/doc/api/vm.md index b0b550093d7f4d..2c9f59515d8986 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -575,16 +575,6 @@ const contextifiedObject = vm.createContext({ })(); ``` -### `module.dependencySpecifiers` - -* {string\[]} - -The specifiers of all dependencies of this module. The returned array is frozen -to disallow any changes to it. - -Corresponds to the `[[RequestedModules]]` field of [Cyclic Module Record][]s in -the ECMAScript specification. - ### `module.error` * {any} @@ -889,6 +879,82 @@ const cachedData = module.createCachedData(); const module2 = new vm.SourceTextModule('const a = 1;', { cachedData }); ``` +### `sourceTextModule.dependencySpecifiers` + + + +> Stability: 0 - Deprecated: Use [`sourceTextModule.moduleRequests`][] instead. + +* {string\[]} + +The specifiers of all dependencies of this module. The returned array is frozen +to disallow any changes to it. + +Corresponds to the `[[RequestedModules]]` field of [Cyclic Module Record][]s in +the ECMAScript specification. + +### `sourceTextModule.moduleRequests` + + + +* {ModuleRequest\[]} Dependencies of this module. + +The requested import dependencies of this module. The returned array is frozen +to disallow any changes to it. + +For example, given a source text: + + + +```mjs +import foo from 'foo'; +import fooAlias from 'foo'; +import bar from './bar.js'; +import withAttrs from '../with-attrs.ts' with { arbitraryAttr: 'attr-val' }; +import source Module from 'wasm-mod.wasm'; +``` + + + +The value of the `sourceTextModule.moduleRequests` will be: + +```js +[ + { + specifier: 'foo', + attributes: {}, + phase: 'evaluation', + }, + { + specifier: 'foo', + attributes: {}, + phase: 'evaluation', + }, + { + specifier: './bar.js', + attributes: {}, + phase: 'evaluation', + }, + { + specifier: '../with-attrs.ts', + attributes: { arbitraryAttr: 'attr-val' }, + phase: 'evaluation', + }, + { + specifier: 'wasm-mod.wasm', + attributes: {}, + phase: 'source', + }, +]; +``` + ## Class: `vm.SyntheticModule` + +* {Object} + * `specifier` {string} The specifier of the requested module. + * `attributes` {Object} The `"with"` value passed to the + [WithClause][] in a [ImportDeclaration][], or an empty object if no value was + provided. + * `phase` {string} The phase of the requested module (`"source"` or `"evaluation"`). + +A `ModuleRequest` represents the request to import a module with given import attributes and phase. + ## `vm.compileFunction(code[, params[, options]])`