assembleWasmPackage function

Future<Directory> assembleWasmPackage({
  1. required BuiltModule module,
  2. required Directory output,
  3. required Map<String, Object?> metadata,
  4. Map<String, File> assets = const {},
})

Assemble an npm package from an already built Dart Wasm module.

Only the known runtime artifacts and explicitly selected documentation assets are copied. metadata retains caller-owned JSON fields, including author and contributors. Entrypoints, exports and the file list belong to this builder; supplying those fields is an error rather than a silent override.

Existing managed output follows the same rebuild rules. Use assembleNativePackage for native artifacts; this function has no backend fallback.

Implementation

Future<Directory> assembleWasmPackage({
  required BuiltModule module,
  required Directory output,
  required Map<String, Object?> metadata,
  Map<String, File> assets = const {},
}) async {
  if (module.target != BuildTarget.wasm) {
    throw ArgumentError('assembleWasmPackage requires a Wasm module.');
  }
  return _assemblePackage(
    modules: [module],
    rootTarget: module.target,
    output: output,
    metadata: metadata,
    assets: assets,
  );
}