Class: ModuleGraph

lib/bundler/graph.ModuleGraph(options)

The module graph for one bundle.

Constructor

new ModuleGraph(options)

Parameters:
Name Type Description
options object

Graph options.

Properties
Name Type Description
resolver Resolver

Specifier resolution.

Source:

Members

cycles :Array:.<Array:.<string:>>

Type:
  • Array:.<Array:.<string:>>
Source:

cyclicEdges :Set:.<string:>

Type:
  • Set:.<string:>
Source:

entries :Array:.<string:>

Type:
  • Array:.<string:>
Source:

modules :Map:.<string:, GraphModule:>

Type:
  • Map:.<string:, GraphModule:>
Source:

resolver :Resolver

Type:
  • Resolver
Source:

Methods

addEntry(id) → {GraphModule}

Adds an entry module and everything reachable from it.

Parameters:
Name Type Description
id string

The resolved entry id.

Source:
Returns:

The entry module.

Type
GraphModule

isCyclicEdge(from, to) → {boolean}

Whether an edge closes a cycle.

Parameters:
Name Type Description
from string

Importing module id.

to string

Imported module id.

Source:
Returns:

True when the import is a back edge.

Type
boolean

resolveExportNames() → {void}

Computes each module's export names, following re-exports and export *.

Runs after every module is loaded, because export * from './x.js' cannot be answered until x.js itself has been read.

Source:
Returns:
Type
void

topologicalOrder() → {Array:.<string:>}

Orders modules so a dependency is emitted before its dependants.

Depth-first post-order. When the walk meets a module already on the stack it has found a cycle: the cycle is recorded for diagnostics and the edge that closes it is marked, so the emitter knows which bindings cannot be read at module-initialisation time.

Source:
Returns:

Module ids in emission order.

Type
Array:.<string:>

validateBindings() → {void}

Checks that every imported name is actually exported.

Only ES modules are checked, and only when the target is an ES module: a CommonJS target has no static export list, and a wildcard entry (*) stands for "cannot be known".

Source:
Throws:

When a module imports a name that does not exist.

Type
BindingError
Returns:
Type
void