Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/deno_graph/mod.ts>ModuleGraph

The module graph logic for Deno CLI
Go to Latest
class ModuleGraph
Re-export
import { ModuleGraph } from "https://deno.land/x/deno_graph@0.38.0/mod.ts";

An interface to the web assembly structure of a built module graph.

Constructors

new
private
ModuleGraph()

Properties

readonly
modules: Module[]

The modules that are part of the module graph.

readonly
roots: string[]

The root specifiers that were used to build the module graph from.

Methods

free(): void

Explicitly free the memory used by the module graph. The web assembly bindings does use weak references, meaning that the memory should be automatically garbage collected when the graph falls out of use.

get(specifier: string): Module | undefined

Retrieve a module from the module graph, if an error was encountered when loading the module, this method will throw with that error.

lock(): void

Determine if the graph sources are valid by calling the passed check() function. If any of the modules in the graph fail the check, then an error is thrown.

resolve(specifier: string): string

Given a string URL, return the resolved string URL accounting for any redirections that might have occurred when resolving the module graph.

resolveDependency(specifier: string, referrer: string): string | undefined

Given a string specifier of a module's dependency and the referring module's string URL, return the string URL of the dependency, otherwise return undefined.

Returns a plain-object representation of the module graph suitable for serialization as JSON, similar to the deno info --json output.

toString(noColor?: boolean): string

Provides a string output representation of the module graph similar to deno info with or without ANSI color escape sequences. If noColor is expressly true, the string will be returned without color escape sequences. If noColor is expressly false the returned string will include ANSI color escape sequences. If not expressly set, Deno.noColor will be used, or if the Deno namespace isn't present, will default to true and not provide ANSI color escape sequences.