parseArchive = async (
  archiveBytes,
  archiveLocation = '<unknown>',
  options = {},
) => {
  await null;
  const {
    computeSha512 = undefined,
    expectedSha512 = undefined,
    computeSourceLocation = undefined,
    computeSourceMapLocation = undefined,
    Compartment: CompartmentParseOption = Compartment,
    modules = undefined,
    importHook: exitModuleImportHook = undefined,
    parserForLanguage: parserForLanguageOption = {},
    __native__ = false,
  } = options;

  const parserForLanguage = freeze(
    assign(create(null), parserForLanguageOption),
  );

  const archive = new ZipReader(archiveBytes, { name: archiveLocation });

  // Track all modules that get loaded, all files that are used.
  const unseen = new Set(archive.files.keys());
  unseen.size >= 2 ||
    Fail`Archive failed sanity check: should contain at least a compartment map file and one module file in ${q(
      archiveLocation,
    )}`;

  /**
   * @param {string} path
   */
  const get = path => {
    unseen.delete(path);
    return archive.read(path);
  };

  const compartmentMapBytes = get('compartment-map.json');

  let sha512;
  if (computeSha512 !== undefined) {
    sha512 = computeSha512(compartmentMapBytes);
  }
  if (expectedSha512 !== undefined) {
    if (sha512 === undefined) {
      throw Error(
        `Cannot verify expectedSha512 without also providing computeSha512, for archive ${archiveLocation}`,
      );
    }
    if (sha512 !== expectedSha512) {
      throw Error(
        `Archive compartment map failed a SHA-512 integrity check, expected ${expectedSha512}, got ${sha512}, for archive ${archiveLocation}`,
      );
    }
  }
  const compartmentMapText = textDecoder.decode(compartmentMapBytes);
  const compartmentMap = parseLocatedJson(
    compartmentMapText,
    'compartment-map.json',
  );
  assertCompartmentMap(compartmentMap, archiveLocation);

  const {
    compartments,
    entry: { module: entryModuleSpecifier, compartment: entryCompartmentName },
  } = compartmentMap;

  const compartmentExitModuleImportHook = exitModuleImportHookMaker({
    modules,
    exitModuleImportHook,
    entryCompartmentName,
  });

  // Archive integrity checks: ensure every module is pre-loaded so its hash
  // gets checked, and ensure that every file in the archive is used, and
  // therefore checked.
  if (computeSha512 !== undefined) {
    const makeImportHook = makeArchiveImportHookMaker(
      get,
      compartments,
      archiveLocation,
      parserForLanguage,
      computeSha512,
      computeSourceLocation,
      compartmentExitModuleImportHook,
      computeSourceMapLocation,
    );
    // A weakness of the current Compartment design is that the `modules` map
    // must be given a module namespace object that passes a brand check.
    // We don't have module instances for the preload phase, so we supply fake
    // namespaces.
    const { compartment, pendingJobsPromise } = link(compartmentMap, {
      makeImportHook,
      parserForLanguage,
      modules: Object.fromEntries(
        Object.keys(modules || {}).map(specifier => {
          return [specifier, { namespace: {} }];
        }),
      ),
      Compartment: CompartmentParseOption,
      __native__,
    });

    await pendingJobsPromise;

    await compartment.load(entryModuleSpecifier);
    unseen.size === 0 ||
      Fail`Archive contains extraneous files: ${q([...unseen])} in ${q(
        archiveLocation,
      )}`;
  }

  /** @type {ExecuteFn} */
  const execute = async options => {
    const {
      globals,
      modules,
      transforms,
      __shimTransforms__,
      Compartment: CompartmentOption = CompartmentParseOption,
      __native__,
      importHook: exitModuleImportHook,
    } = options || {};

    const compartmentExitModuleImportHook = exitModuleImportHookMaker({
      modules,
      exitModuleImportHook,
      entryCompartmentName,
    });
    const makeImportHook = makeArchiveImportHookMaker(
      get,
      compartments,
      archiveLocation,
      parserForLanguage,
      computeSha512,
      computeSourceLocation,
      compartmentExitModuleImportHook,
      computeSourceMapLocation,
    );
    const { compartment, pendingJobsPromise } = link(compartmentMap, {
      makeImportHook,
      parserForLanguage,
      globals,
      modules,
      transforms,
      __shimTransforms__,
      Compartment: CompartmentOption,
      __native__,
    });

    await pendingJobsPromise;

    // eslint-disable-next-line dot-notation
    return compartment['import'](entryModuleSpecifier);
  };

  return { import: execute, sha512 };
}
@param {Uint8Array} archiveBytes
@param {string} [archiveLocation]
@param {ParseArchiveOptions} [options]
@returns {Promise<Application>}