Skip to content

SourceTextModule

[<Interface>]
type SourceTextModule =
    abstract member dependencySpecifiers: string array
    abstract member moduleRequests: ModuleRequest array
    static member Create (dependencySpecifiers: string array, moduleRequests: ModuleRequest array, error: obj, identifier: string, context: Context, namespace: Object, status: ModuleStatus, evaluate: ModuleEvaluateOptions option -> Promise<unit>, link: ModuleLinker -> Promise<unit>) : SourceTextModule
AssemblyXantham.Fable.Node
ImplementsModule
Attributes[<Interface>]

This feature is only available with the --experimental-vm-modules command flag enabled.

The vm.SourceTextModule class provides the Source Text Module Record as defined in the ECMAScript specification.

@since v9.6.0

Properties

abstract member dependencySpecifiers: string array

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 Records in the ECMAScript specification.

@deprecated Use {@link moduleRequests} instead.

abstract member moduleRequests: ModuleRequest array

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

The value of the sourceTextModule.moduleRequests will be:

[
{
specifier: 'foo',
attributes: {},
},
{
specifier: 'foo',
attributes: {},
},
{
specifier: './bar.js',
attributes: {},
},
{
specifier: '../with-attrs.ts',
attributes: { arbitraryAttr: 'attr-val' },
},
];

@since v22.20.0

Methods

static member Create (dependencySpecifiers: string array, moduleRequests: ModuleRequest array, error: obj, identifier: string, context: Context, namespace: Object, status: ModuleStatus, evaluate: ModuleEvaluateOptions option -> Promise<unit>, link: ModuleLinker -> Promise<unit>) : SourceTextModule