registerLibraryReExport method

void registerLibraryReExport(
  1. String sourceUri,
  2. String targetUri, {
  3. Set<String>? show,
  4. Set<String>? hide,
})

GEN-107: Registers a re-export from one library to another.

Mirrors Dart's export 'other/library.dart' [show/hide …] directive: records that sourceUri re-exports symbols from targetUri, with optional show and hide filters.

The recorded entries are consumed by ModuleLoader._mergeReExportsGlobal when a bridged library is imported. That method loads bridges for every transitively re-exported target into globalEnvironment, so a script that imports package:flutter/material.dart automatically gets Widget (registered under package:flutter/widgets.dart) without importing widgets.dart explicitly. This mirrors what AstModuleLoader._mergeReExports does for the AST-based pipeline. Generated bridge code can call this on either interpreter without branching.

sourceUri The library doing the re-exporting (e.g. package:flutter/services.dart). targetUri The library being re-exported (e.g. dart:typed_data). show Optional set of names to include from targetUri. hide Optional set of names to exclude from targetUri.

Implementation

void registerLibraryReExport(
  String sourceUri,
  String targetUri, {
  Set<String>? show,
  Set<String>? hide,
}) {
  final reExport = (uri: targetUri, show: show, hide: hide);
  _libraryReExports.putIfAbsent(sourceUri, () => []).add(reExport);
  // Step 7: dual-write into the process-global pool (see registerBridgedEnum).
  _bundleFor().libraryReExports
      .putIfAbsent(sourceUri, () => [])
      .add(reExport);
}