0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-20 22:12:38 -05:00

tmp function in pipeline.ts

This commit is contained in:
Goulven Clec'h 2024-04-09 15:51:19 +02:00
parent 8ef0d88a71
commit 98e9e90d7a
2 changed files with 15 additions and 3 deletions

View file

@ -186,9 +186,13 @@ export class BuildPipeline extends Pipeline {
entrypoint.includes(RESOLVED_SPLIT_MODULE_ID)
) {
const [, pageName] = entrypoint.split(':');
const pageData = this.internals.pagesByKeys.get(
`${pageName.replace(ASTRO_PAGE_EXTENSION_POST_PATTERN, '.')}`
console.log('pageName', pageName);
// TODO: Change that
const pageData = tmp(
this.internals.pagesByKeys,
pageName.replace(ASTRO_PAGE_EXTENSION_POST_PATTERN, '.')
);
if (!pageData) {
throw new Error(
"Build failed. Astro couldn't find the emitted page from " + pageName + ' pattern'
@ -229,3 +233,12 @@ export class BuildPipeline extends Pipeline {
return pages;
}
}
/**
* TMP: This is a temporary function to get the page data from the pagesByKeys map.
*/
function tmp(pagesByKeys: Map<string, any>, pageName: string) {
for (const pages of pagesByKeys.values()) {
if (pages.component == pageName) return pages;
}
}

View file

@ -43,7 +43,6 @@ function vitePluginPages(opts: StaticBuildOptions, internals: BuildInternals): V
const exports: string[] = [];
const pageName = getPathFromVirtualModulePageName(ASTRO_PAGE_RESOLVED_MODULE_ID, id);
// TODO: Change that
// const pageData = internals.pagesByKeys.get(pageName);
const pageData = tmp(internals.pagesByKeys, pageName);
if (pageData) {
const resolvedPage = await this.resolve(pageData.moduleSpecifier);