assemblePackage function

Future<Directory> assemblePackage({
  1. required List<BuiltModule> modules,
  2. required Directory output,
  3. required Map<String, Object?> metadata,
  4. BuildTarget target = BuildTarget.native,
  5. bool wasmFallback = false,
  6. Map<String, File> assets = const {},
})

Assemble separately built platforms and optional Wasm into one npm package.

Build each native module on its target host with buildLibrary, then copy the complete output directory, including its ownership record. Modules must have matching public declarations, conversions and defaults. Assembly does not load native code or require a native build host.

target selects the root backend. The native entry selects the current platform from the bundled artifacts and never falls back to Wasm. All selected artifacts ship in the package; there are no install-time downloads. wasmFallback enables Wasm on unsupported platforms for root ESM imports when both backends are supplied and target is native.

Implementation

Future<Directory> assemblePackage({
  required List<BuiltModule> modules,
  required Directory output,
  required Map<String, Object?> metadata,
  BuildTarget target = BuildTarget.native,
  bool wasmFallback = false,
  Map<String, File> assets = const {},
}) => _assemblePackage(
  modules: List.of(modules),
  rootTarget: target,
  output: output,
  metadata: metadata,
  assets: assets,
  platformSelection: true,
  wasmFallback: wasmFallback,
);