JsModule Class
A Module Record (https://tc39.es/ecma262/#sec-abstract-module-records). A module is loaded (JsModule.LoadRequestedModules), linked (JsModule.Link), then evaluated (JsModule.Evaluate).
public abstract class JsModule : JsScriptOrModule- Inheritance
JsScriptOrModuleJsModule
Properties
| Name | Description |
|---|---|
| EvaluationError | Gets the error thrown by the evaluation of the module ([[EvaluationError]]), or undefined. |
| EvaluationErrorLocation | Gets the position of the code that threw JsModule.EvaluationError, when the error was thrown synchronously by the evaluation of a module of the graph. |
| HasEvaluationError | Gets whether the evaluation of the module threw an error. |
| ModuleSource | Gets or sets the module source object of the module ([[ModuleSource]], https://tc39.es/proposal-source-phase-imports/): the value of a source phase import of the module (import source x from and import.source()), e.g. a WebAssembly.Module. The host sets it when it creates the module, before the module loader returns it. The object should extend JsRealm.AbstractModuleSource and be a JsHostObject whose JsHostObject.ModuleSourceClassName is set. When it is null (e.g. a JavaScript or a JSON module), a source phase import of the module throws a SyntaxError. |
| Status | Gets the status of the module. |
EvaluationError
JsModule.csEvaluationErrorLocation
JsModule.csGets the position of the code that threw JsModule.EvaluationError, when the error was thrown synchronously by the evaluation of a module of the graph.
public JsSourceLocation? EvaluationErrorLocation { get; }Property value
HasEvaluationError
JsModule.csModuleSource
JsModule.csGets or sets the module source object of the module ([[ModuleSource]], https://tc39.es/proposal-source-phase-imports/): the value of a source phase import of the module (import source x from and import.source()), e.g. a WebAssembly.Module. The host sets it when it creates the module, before the module loader returns it. The object should extend JsRealm.AbstractModuleSource and be a JsHostObject whose JsHostObject.ModuleSourceClassName is set. When it is null (e.g. a JavaScript or a JSON module), a source phase import of the module throws a SyntaxError.
public JsObject? ModuleSource { get; set; }Property value
Status
JsModule.csMethods
| Name | Description |
|---|---|
| Evaluate() | Evaluates the module and its dependencies (Evaluate). |
| GetNamespace() | Gets the namespace object of the module (GetModuleNamespace). The module must be linked. |
| Link() | Links the module and its dependencies (Link): creates the environments and resolves the imports. |
| LoadRequestedModules(object?) | Loads the dependencies of the module, recursively (LoadRequestedModules). |
Evaluate()
JsModule.csGetNamespace()
JsModule.csLink()
JsModule.csLinks the module and its dependencies (Link): creates the environments and resolves the imports.
public void Link()Exceptions
JsException- An import cannot be resolved (a SyntaxError).
LoadRequestedModules(object?)
JsModule.csLoads the dependencies of the module, recursively (LoadRequestedModules).