verify method

void verify()

Link the import graph in a scratch engine without executing any module. Throws a JSError naming the specifiers that are not part of the bundle.

Implementation

void verify() {
  final missing = <String>[];
  final scratch = QuickJsRuntime2(
    memoryLimit: 0,
    webApis: const JsWebApis.none(),
    moduleHandler: (name) {
      missing.add(name);
      throw JSError('module "$name" is not part of the bundle');
    },
  );
  try {
    install(scratch, resolveEntry: true);
  } on JSError catch (error) {
    if (missing.isEmpty) rethrow;
    throw JSError(
      'JsModuleBundle("$entry") is incomplete: missing '
      '${missing.toSet().join(', ')}',
      error.stack,
    );
  } finally {
    scratch.dispose();
  }
}