pub struct ModuleGraph {
    pub roots: Vec<(ModuleSpecifier, ModuleKind)>,
    pub imports: Vec<GraphImport>,
    pub redirects: BTreeMap<ModuleSpecifier, ModuleSpecifier>,
    /* private fields */
}
Expand description

The structure which represents a module graph, which can be serialized as well as “printed”. The roots of the graph represent the “starting” point which can be located in the module “slots” in the graph. The graph also contains any redirects where the requested module specifier was redirected to another module specifier when being loaded.

Fields

roots: Vec<(ModuleSpecifier, ModuleKind)>imports: Vec<GraphImport>redirects: BTreeMap<ModuleSpecifier, ModuleSpecifier>

Implementations

Returns true if the specifier resolves to a module within a graph, otherwise returns false.

Returns any errors that are in the module graph.

Get a module from the module graph, returning None if the module is not part of the graph, or if when loading the module it errored. If any module resolution error is needed, then use the try_get() method which will return any resolution error as the error in the result.

Determine if the graph sources are valid by calling the passed locker. If the integrity of all the sources passes or if there is no locker supplied the method results in an ok, otherwise returns an error which indicates the first specifier that failed the integrity check.

Return a vector of references to ES module objects in the graph. Only ES modules that were fully resolved are present, as “errors” are omitted. If you need to know what errors are in the graph, use the .errors() method, or if you just need to check if everything is “ok” with the graph, use the .valid() method.

Returns a map of the fully resolved dependency graph of the module graph.

Resolve a specifier from the module graph following any possible redirects returning the “final” module.

Resolve a dependency of a referring module providing the string specifier of the dependency and returning an optional fully qualified module specifier.

The prefer_types flags indicates if a type dependency is preferred over a code dependency. If true, a type dependency will be returned in favor of a code dependency. If false a code dependency will be returned in favor of a type dependency. The value should be set to true when resolving specifiers for type checking, or otherwise false.

Return a map representation of the specifiers in the graph, where each key is a module specifier and each value is a result that contains a tuple of the module specifier, module kind, and media type, or the module graph error.

Retrieve a module from the module graph. If the module identified as a dependency of the graph, but resolving or loading that module resulted in an error, the error will be returned as the Err of the result. If the module is not part of the graph, or the module is missing from the graph, the result will be Ok with the option of the module.

Walk the graph from the root, checking to see if there are any module graph errors on non-type only, non-dynamic imports. The first error is returned as as error result, otherwise ok if there are no errors.

Walk the graph from the root, checking to see if there are any module graph errors on non-dynamic imports that are type only related. The first error is returned as an error result, otherwise ok if there are no errors.

This is designed to be used in cases where the graph needs to be validated from a type checking perspective, prior to type checking the graph.

Trait Implementations

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more