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

x/deno_graph/mod.ts>CreateGraphOptions

The module graph logic for Deno CLI
Go to Latest
interface CreateGraphOptions
import { type CreateGraphOptions } from "https://deno.land/x/deno_graph@0.50.0/mod.ts";

Properties

optional
kind: "all" | "typesOnly" | "codeOnly"

The type of graph to build. "all" includes all dependencies of the roots. "typesOnly" skips any code only dependencies that do not impact the types of the graph, and "codeOnly" only includes dependencies that are runnable code.

optional
defaultJsxImportSource: string

The default jsxImportSource to use in JSX/TSX files when no @jsxImportSource pragma is specified. In Deno, this is set to the compilerOptions.jsxImportSource value if compilerOptions.jsx is set to react-jsx or react-jsxdev.

optional
jsxImportSourceModule: string

When identifying a @jsxImportSource pragma, what module name will be appended to the import source. This defaults to jsx-runtime.

optional
imports: Record<string, string[]>

An optional record of "injected" dependencies to the module graph. This allows adding things like TypeScript's "types" values into the graph or a JSX runtime. The key is the referrer specifier to use as a base when resolving relative specifiers. The value is any module specifiers that are being imported.

Methods

optional
load(specifier: string, isDynamic: boolean): Promise<LoadResponse | undefined>

A callback that is called with the URL string of the resource to be loaded and a flag indicating if the module was required dynamically. The callback should resolve with a LoadResponse or undefined if the module is not found. If there are other errors encountered, a rejected promise should be returned.

optional
cacheInfo(specifier: string): CacheInfo

An optional callback that will be called with a URL string of the resource to provide additional meta data about the resource to enrich the module graph.

optional
resolve(specifier: string, referrer: string): string

An optional callback that allows the default resolution logic of the module graph to be "overridden". This is intended to allow items like an import map to be used with the module graph. The callback takes the string of the module specifier from the referrer and the string URL of the referrer. The callback then returns a fully qualified resolved URL string specifier.

optional
resolveTypes(specifier: string): TypesDependency | undefined

An optional callback that can allow custom logic of how type dependencies of a module to be provided. This will be called if a module is being added to the graph that is is non-typed source code (e.g. JavaScript/JSX) and allow resolution of a type only dependency for the module (e.g. @types or a .d.ts file).