Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ export async function executePostBundleSteps(
}

const serializableRouteTreeNodeForManifest: WritableSerializableRouteTreeNode = [];

for (const metadata of serializableRouteTreeNode) {
serializableRouteTreeNodeForManifest.push(metadata);

Expand Down
11 changes: 11 additions & 0 deletions packages/angular/build/src/utils/server-rendering/prerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { assertIsError } from '../error';
import { urlJoin } from '../url';
import { WorkerPool } from '../worker-pool';
import { IMPORT_EXEC_ARGV } from './esm-in-memory-loader/utils';
import { SERVER_APP_MANIFEST_FILENAME } from './manifest';
import {
RouteRenderMode,
RoutersExtractorWorkerResult,
Expand Down Expand Up @@ -156,6 +157,16 @@ export async function prerenderPages(
};
}

// Add the extracted routes to the manifest file.
// We could re-generate it from the start, but that would require a number of options to be passed down.
const manifest = outputFilesForWorker[SERVER_APP_MANIFEST_FILENAME];
if (manifest) {
outputFilesForWorker[SERVER_APP_MANIFEST_FILENAME] = manifest.replace(
'routes: undefined,',
`routes: ${JSON.stringify(serializableRouteTreeNodeForPrerender, undefined, 2)},`,
);
}

// Render routes
const { errors: renderingErrors, output } = await renderPages(
baseHref,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ export default async function () {
await replaceInFile('src/app/app.routes.server.ts', 'RenderMode.Server', 'RenderMode.Prerender');
await noSilentNg('build', '--output-mode=static');

const expects: Record<string, string> = {
'index.html': 'home works!',
'ssg/index.html': 'ssg works!',
'ssg/one/index.html': 'ssg-with-params works!',
'ssg/two/index.html': 'ssg-with-params works!',
const expects: Record<string, RegExp | string> = {
'index.html': /ng-server-context="ssg".+home works!/,
'ssg/index.html': /ng-server-context="ssg".+ssg works!/,
'ssg/one/index.html': /ng-server-context="ssg".+ssg-with-params works!/,
'ssg/two/index.html': /ng-server-context="ssg".+ssg-with-params works!/,
// When static redirects as generated as meta tags.
'ssg-redirect/index.html': '<meta http-equiv="refresh" content="0; url=/ssg">',
};
Expand Down
Loading