Skip to main content
Home

@deno/graph@0.96.2
Built and signed on GitHub Actions

The module graph logic for Deno CLI.

This package works with Deno
This package works with Deno
JSR Score
70%
Published
2 weeks ago (0.96.2)
interface CreateGraphOptions

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.

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.

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

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,
cacheSetting: CacheSetting,
checksum: string | undefined,
): 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).

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@deno/graph

Import symbol

import { type CreateGraphOptions } from "@deno/graph";
or

Import directly with a jsr specifier

import { type CreateGraphOptions } from "jsr:@deno/graph";