diff --git a/packages/compartment-mapper/src/import-archive.js b/packages/compartment-mapper/src/import-archive.js index c3248cfdad..5eeffd8065 100644 --- a/packages/compartment-mapper/src/import-archive.js +++ b/packages/compartment-mapper/src/import-archive.js @@ -208,9 +208,13 @@ const makeArchiveImportHookMaker = ( return makeImportHook; }; -const makeFeauxModuleExportsNamespace = Compartment => { - // @ts-ignore Unclear at time of writing why Compartment type is not - // constructible. +/** + * Creates a fake module namespace object that passes a brand check. + * + * @param {typeof Compartment} Compartment + * @returns {import('ses').ModuleExportsNamespace} + */ +const makeFauxModuleExportsNamespace = Compartment => { const compartment = new Compartment( {}, {}, @@ -218,10 +222,11 @@ const makeFeauxModuleExportsNamespace = Compartment => { resolveHook() { return '.'; }, - importHook() { + async importHook() { return { imports: [], execute() {}, + exports: [], }; }, }, @@ -336,7 +341,7 @@ export const parseArchive = async ( parserForLanguage, modules: Object.fromEntries( Object.keys(modules || {}).map(specifier => { - return [specifier, makeFeauxModuleExportsNamespace(Compartment)]; + return [specifier, makeFauxModuleExportsNamespace(Compartment)]; }), ), Compartment,