Skip to content

Commit 292a4b7

Browse files
committedOct 9, 2024·
feat(@schematics/angular): update app-shell and ssr schematics to adopt new Server Rendering API
This commit revises the app-shell and ssr schematics to incorporate the new Server Rendering API, along with the integration of server-side routes. BREAKING CHANGE: The app-shell schematic is no longer compatible with Webpack-based builders.
1 parent 1bb68ba commit 292a4b7

File tree

46 files changed

+510
-696
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+510
-696
lines changed
 

‎packages/angular/build/src/builders/application/execute-post-bundle.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
} from '../../utils/server-rendering/models';
3030
import { prerenderPages } from '../../utils/server-rendering/prerender';
3131
import { augmentAppWithServiceWorkerEsbuild } from '../../utils/service-worker';
32-
import { INDEX_HTML_SERVER, NormalizedApplicationBuildOptions } from './options';
32+
import { INDEX_HTML_CSR, INDEX_HTML_SERVER, NormalizedApplicationBuildOptions } from './options';
3333
import { OutputMode } from './schema';
3434

3535
/**
@@ -154,7 +154,15 @@ export async function executePostBundleSteps(
154154
// Update the index contents with the app shell under these conditions:
155155
// - Replace 'index.html' with the app shell only if it hasn't been prerendered yet.
156156
// - Always replace 'index.csr.html' with the app shell.
157-
const filePath = appShellRoute && !indexHasBeenPrerendered ? indexHtmlOptions.output : path;
157+
let filePath = path;
158+
if (appShellRoute && !indexHasBeenPrerendered) {
159+
if (outputMode !== OutputMode.Server && indexHtmlOptions.output === INDEX_HTML_CSR) {
160+
filePath = 'index.html';
161+
} else {
162+
filePath = indexHtmlOptions.output;
163+
}
164+
}
165+
158166
additionalHtmlOutputFiles.set(
159167
filePath,
160168
createOutputFile(filePath, content, BuildOutputFileType.Browser),

‎packages/angular/build/src/utils/server-rendering/prerender.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ async function renderPages(
213213
outputFiles: outputFilesForWorker,
214214
assetFiles: assetFilesForWorker,
215215
outputMode,
216-
hasSsrEntry: !!outputFilesForWorker['/server.mjs'],
216+
hasSsrEntry: !!outputFilesForWorker['server.mjs'],
217217
} as RenderWorkerData,
218218
execArgv: workerExecArgv,
219219
});
@@ -319,7 +319,7 @@ async function getAllRoutes(
319319
outputFiles: outputFilesForWorker,
320320
assetFiles: assetFilesForWorker,
321321
outputMode,
322-
hasSsrEntry: !!outputFilesForWorker['/server.mjs'],
322+
hasSsrEntry: !!outputFilesForWorker['server.mjs'],
323323
} as RoutesExtractorWorkerData,
324324
execArgv: workerExecArgv,
325325
});

0 commit comments

Comments
 (0)
Please sign in to comment.