method

ModuleGraph.dispose

dispose(): void;

Closes everything the graph's code opened (and disposes any graph its code made), and drops the graph's modules: graph.import() and graph.run() fail from here on, the graph's require() throws, and modules that had not run yet never will.

The graph is told nothing, like a worker that was terminated: no close handler, onExit or 'error' event is called, and no promise is settled — one waiting on the graph's work (a fetch(), a child's exited, an import() still loading) stays pending. Microtasks and process.nextTick callbacks it had already queued still run once; what they start reports nothing either. Objects the graph's code made (a socket, a worker, a stream) no longer work, for the host either.

Not a sandbox: synchronous calls run to completion. Idempotent.