exitModuleImportHookMaker = ({
  modules = undefined,
  exitModuleImportHook = undefined,
  entryCompartmentName,
}) => {
  if (!modules && !exitModuleImportHook) {
    return undefined;
  }
  return async specifier => {
    if (modules && has(modules, specifier)) {
      const ns = modules[specifier];
      return freeze({
        imports: [],
        exports: ns ? keys(ns) : [],
        execute: moduleExports => {
          moduleExports.default = ns;
          assign(moduleExports, ns);
        },
      });
    }
    if (exitModuleImportHook) {
      // The entryCompartmentName is a file URL when constructing an archive or
      // importing from a file system, but is merely a zip archive root
      // directory name when importing from an archive.
      return exitModuleImportHook(specifier, entryCompartmentName);
    }
    return undefined;
  };
}
@param {object} params
@param {Record<string, any>} [params.modules]
@param {ExitModuleImportHook} [params.exitModuleImportHook]
@param {string} params.entryCompartmentName
@returns {ExitModuleImportHook|undefined}