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 { } else {
const importComponentInstance = this.#manifest.pageMap.get(route.component); const importComponentInstance = this.#manifest.pageMap.get(route.component);
if(!importComponentInstance) { 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(); const built = await importComponentInstance();
return built.page(); return built.page();

View file

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

View file

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