From e41e2015bfc37672fb67014ae38f31b63f0bb256 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Sat, 9 Sep 2023 09:37:23 +0000 Subject: [PATCH] fix(@angular-devkit/build-angular): avoid spawning workers when there are no routes to prerender This commit fixes an issue were previously we spawned piscina with `maxThreads` set to `0` which causes it to exit with a non zero error code when there are no routes to prerender. Now, in the application builder we exit at n earlier stage if there are no routes to prerender. --- .../src/utils/server-rendering/prerender.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/angular_devkit/build_angular/src/utils/server-rendering/prerender.ts b/packages/angular_devkit/build_angular/src/utils/server-rendering/prerender.ts index d03d4821fd72..dc3eb7ecd4cc 100644 --- a/packages/angular_devkit/build_angular/src/utils/server-rendering/prerender.ts +++ b/packages/angular_devkit/build_angular/src/utils/server-rendering/prerender.ts @@ -37,7 +37,19 @@ export async function prerenderPages( warnings: string[]; errors: string[]; }> { + const output: Record = {}; + const warnings: string[] = []; + const errors: string[] = []; const allRoutes = await getAllRoutes(tsConfigPath, appShellOptions, prerenderOptions); + + if (allRoutes.size < 1) { + return { + errors, + warnings, + output, + }; + } + const outputFilesForWorker: Record = {}; for (const { text, path } of outputFiles) { @@ -65,10 +77,6 @@ export async function prerenderPages( ], }); - const output: Record = {}; - const warnings: string[] = []; - const errors: string[] = []; - try { const renderingPromises: Promise[] = [];