loadModule method

  1. @override
LoadedModule loadModule(
  1. Uri uri, {
  2. Set<String>? showNames,
  3. Set<String>? hideNames,
})
override

Loads (or returns the cached) module for uri.

DFUB10 — the real work lives in _loadModule; this wrapper only guarantees that a failed load drops its in-flight registration, so an abandoned partial is never handed out on a later execute.

GitHub #9 — when the OUTERMOST load returns, what was handed to deferUntilModulesLoaded runs: by then every module of every import cycle has declared its names and every partial merge has been replayed.

Implementation

@override
LoadedModule loadModule(
  Uri uri, {
  Set<String>? showNames,
  Set<String>? hideNames,
}) {
  if (executionContext case final ExecutionRun run) run.checkImport(uri);
  final LoadedModule module;
  _loadDepth++;
  try {
    module = _loadModule(uri, showNames: showNames, hideNames: hideNames);
  } catch (_) {
    _inFlightModules.remove(uri);
    if (--_loadDepth == 0) _deferredUntilLoaded.clear();
    rethrow;
  }
  if (--_loadDepth == 0) _runDeferredUntilLoaded();
  return module;
}