sourceTextModule.moduleRequests


  • ModuleRequest[] 此模块的依赖。

    ¥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:

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'; 

sourceTextModule.moduleRequests 的值将是:

¥The value of the sourceTextModule.moduleRequests will be:

[
  {
    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',
  },
];