0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-03-31 23:31:30 -05:00

fix?: ssr clean static output

This commit is contained in:
Goulven Clec'h 2024-04-25 14:02:28 +02:00
parent ae2b01737d
commit b3ccdfb12c
2 changed files with 12 additions and 6 deletions

View file

@ -47,7 +47,7 @@ import { createRequest } from '../request.js';
import { matchRoute } from '../routing/match.js';
import { getOutputFilename } from '../util.js';
import { getOutDirWithinCwd, getOutFile, getOutFolder } from './common.js';
import { cssOrder, getPageDataByComponent, mergeInlineCss } from './internal.js';
import { cssOrder, getPageData, mergeInlineCss } from './internal.js';
import { BuildPipeline } from './pipeline.js';
import type {
PageBuildData,
@ -257,7 +257,7 @@ async function generatePage(
const { config, internals, logger } = pipeline;
const pageModulePromise = ssrEntry.page;
// TODO: Why do we need to get PageData from PageData?
const pageInfo = getPageDataByComponent(internals, pageData.route.component);
const pageInfo = getPageData(internals, pageData.route.component, pageData.route.route);
// Calculate information of the page, like scripts, links and styles
const styles = pageData.styles

View file

@ -370,11 +370,17 @@ async function cleanStaticOutput(
) {
const allStaticFiles = new Set();
for (const pageData of internals.pagesByKeys.values()) {
if (pageData.route.prerender && !pageData.hasSharedModules) {
const { moduleSpecifier } = pageData;
const pageBundleId = internals.pageToBundleMap.get(moduleSpecifier);
const entryBundleId = internals.entrySpecifierToBundleMap.get(moduleSpecifier);
console.log("[cleanStaticOutput] pageData: ", pageData.key, "— is prerender ? ", pageData.route.prerender);
const { moduleSpecifier } = pageData;
const pageBundleId = internals.pageToBundleMap.get(moduleSpecifier);
const entryBundleId = internals.entrySpecifierToBundleMap.get(moduleSpecifier);
if (pageData.route.prerender && !pageData.hasSharedModules && allStaticFiles.has(pageBundleId ?? entryBundleId)) {
allStaticFiles.add(pageBundleId ?? entryBundleId);
} else {
// Check if the page pageBundleId or entryBundleId is already in the set, if so, remove it
if (allStaticFiles.has(pageBundleId ?? entryBundleId)) {
allStaticFiles.delete(pageBundleId ?? entryBundleId);
}
}
}
const ssr = isServerLikeOutput(opts.settings.config);