This commit is contained in:
Matthew Phillips 2023-05-30 17:41:24 -04:00
parent 02a8506e22
commit eb7617d719
3 changed files with 6 additions and 18 deletions

View file

@ -177,7 +177,7 @@ export class App {
} else {
const importComponentInstance = this.#manifest.pageMap.get(route.component);
if(!importComponentInstance) {
throw new Error(`Unexpected unable to find a component instance for route ${route.route}`);
throw new Error(`Unexpectedly unable to find a component instance for route ${route.route}`);
}
const built = await importComponentInstance();
return built.page();

View file

@ -150,12 +150,8 @@ export async function generatePages(opts: StaticBuildOptions, internals: BuildIn
}
}
for(const pageData of eachRedirectPageData(internals)) {
// TODO MOVE
await generatePage(opts, internals, pageData, {
page: () => Promise.resolve(RedirectComponentInstance),
middleware: StaticMiddlewareInstance,
renderers: []
}, builtPaths);
const entry = await getEntryForRedirectRoute(pageData.route, internals, outFolder);
await generatePage(opts, internals, pageData, entry, builtPaths);
}
} else {
for (const [pageData, filePath] of eachPageDataFromEntryPoint(internals)) {
@ -166,15 +162,7 @@ export async function generatePages(opts: StaticBuildOptions, internals: BuildIn
}
for(const pageData of eachRedirectPageData(internals)) {
const entry = await getEntryForRedirectRoute(pageData.route, internals, outFolder);
if(pageData.route.redirectRoute) {
const filePath = getEntryFilePathFromComponentPath(internals, pageData.route.redirectRoute.component);
}
await generatePage(opts, internals, pageData, {
page: () => Promise.resolve(RedirectComponentInstance),
middleware: StaticMiddlewareInstance,
renderers: []
}, builtPaths);
await generatePage(opts, internals, pageData, entry, builtPaths);
}
}

View file

@ -15,7 +15,7 @@ import type { AstroBuildPlugin } from '../plugin';
import type { StaticBuildOptions } from '../types';
import { MIDDLEWARE_MODULE_ID } from './plugin-middleware.js';
import { routeIsRedirect } from '../../redirects/index.js';
import { getVirtualModulePageIdFromPath } from './plugin-pages.js';
import { getVirtualModulePageNameFromPath } from './plugin-pages.js';
import { RENDERERS_MODULE_ID } from './plugin-renderers.js';
export const SSR_VIRTUAL_MODULE_ID = '@astrojs-ssr-virtual-entry';
@ -60,7 +60,7 @@ function vitePluginSSR(
if(routeIsRedirect(pageData.route)) {
continue;
}
const virtualModuleName = getVirtualModulePageIdFromPath(path);
const virtualModuleName = getVirtualModulePageNameFromPath(path);
let module = await this.resolve(virtualModuleName);
if (module) {
const variable = `_page${i}`;