mirror of
https://github.com/withastro/astro.git
synced 2025-02-03 22:29:08 -05:00
fix pagesByKeys.get() in plugin-ssr & plugin-manifest
This commit is contained in:
parent
05f1edece4
commit
db7bca55c0
3 changed files with 16 additions and 5 deletions
|
@ -189,8 +189,10 @@ function buildManifest(
|
|||
}
|
||||
|
||||
for (const route of opts.manifest.routes) {
|
||||
// TODO: Change that
|
||||
const pageData = internals.pagesByKeys.get(route.component);
|
||||
let pageData;
|
||||
for (const page of internals.pagesByKeys.values()) {
|
||||
if (page.route.route == route.route) pageData = page;
|
||||
}
|
||||
if (route.prerender || !pageData) continue;
|
||||
const scripts: SerializedRouteInfo['scripts'] = [];
|
||||
if (pageData.hoistedScript) {
|
||||
|
|
|
@ -43,7 +43,8 @@ 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 = internals.pagesByKeys.get(pageName);
|
||||
const pageData = tmp(internals.pagesByKeys, pageName);
|
||||
if (pageData) {
|
||||
const resolvedPage = await this.resolve(pageData.moduleSpecifier);
|
||||
if (resolvedPage) {
|
||||
|
@ -73,3 +74,12 @@ export function pluginPages(opts: StaticBuildOptions, internals: BuildInternals)
|
|||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,8 +55,7 @@ function vitePluginSSR(
|
|||
// we need to use the non-resolved ID in order to resolve correctly the virtual module
|
||||
imports.push(`const ${variable} = () => import("${virtualModuleName}");`);
|
||||
|
||||
// TODO: Change that
|
||||
const pageData2 = internals.pagesByKeys.get(path);
|
||||
const pageData2 = internals.pagesByKeys.get(pageData.key);
|
||||
if (pageData2) {
|
||||
pageMap.push(`[${JSON.stringify(pageData2.component)}, ${variable}]`);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue