diff --git a/packages/pages/src/vite-plugin/build/buildStart/rendering/templateUtils.ts b/packages/pages/src/vite-plugin/build/buildStart/rendering/templateUtils.ts index 10df164a5..9c641517e 100644 --- a/packages/pages/src/vite-plugin/build/buildStart/rendering/templateUtils.ts +++ b/packages/pages/src/vite-plugin/build/buildStart/rendering/templateUtils.ts @@ -13,7 +13,7 @@ import { } from "../../../../common/src/template/internal/types.js"; import { ProjectStructure } from "../../../../common/src/project/structure.js"; -const pathToModule = new Map(); +const pathToModule = new Map>(); /** * @returns an array of template modules matching the document's feature. @@ -33,6 +33,7 @@ export const readTemplateModules = async ( let importedModule = pathToModule.get(path) as TemplateModule; if (!importedModule) { importedModule = await import(path); + pathToModule.set(path, importedModule); } const templateModuleInternal = convertTemplateModuleToTemplateModuleInternal( @@ -41,8 +42,6 @@ export const readTemplateModules = async ( true ); - pathToModule.set(path, templateModuleInternal); - return templateModuleInternal; };