Constructor
new ModuleGraph(options)
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
options |
object | Graph options. Properties
|
- Source:
Members
cycles :Array:.<Array:.<string:>>
Type:
- Source:
cyclicEdges :Set:.<string:>
Type:
- Source:
entries :Array:.<string:>
Type:
- Source:
modules :Map:.<string:, GraphModule:>
Type:
- 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.
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