interface
ModuleGraphOptions
interface ModuleGraphOptions
- globals?: Record<string, unknown>
Values for free identifiers in all of the graph's module code (e.g.
{ process: myProcess, fetch: myFetch }). Graphs constructed with the same set of names share their ES modules' compiled code with each other. - onError?: (error: unknown, kind: 'uncaughtException' | 'unhandledRejection') => void
Called with the uncaught exceptions and unhandled rejections that happen in this graph's context, instead of the process-wide
uncaughtException/unhandledRejectionhandling.kindsays which.An error is the graph's when it happens in the graph's context, whoever wrote the code that threw: the graph's modules and what they start, and what the host calls through ModuleGraph.run. A function of the graph's that the host calls directly runs in the host's context, and its errors are the host's. The promise ModuleGraph.import returns is its caller's.
The handler runs in the context the graph was made in, so what it throws or rejects is that context's: the host's, when the host made the graph.
Without an
onError, errors go to theonErrorof the graph in whose context this graph was made, and to the process-wide path when the host made it.