diff --git a/doc/api/vm.md b/doc/api/vm.md index 309f24fabdce32..c3edcbbcb7b191 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -573,16 +573,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` * Type: {any} @@ -887,6 +877,72 @@ 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' }; +``` + + + +The value of the `sourceTextModule.moduleRequests` will be: + +```js +[ + { + specifier: 'foo', + attributes: {}, + }, + { + specifier: 'foo', + attributes: {}, + }, + { + specifier: './bar.js', + attributes: {}, + }, + { + specifier: '../with-attrs.ts', + attributes: { arbitraryAttr: 'attr-val' }, + }, +]; +``` + ## 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. + +A `ModuleRequest` represents the request to import a module with given import attributes and phase. + ## `vm.compileFunction(code[, params[, options]])`