Skip to content

Commit e41e201

Browse files
committed
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.
1 parent d2f4750 commit e41e201

File tree

1 file changed

+12
-4
lines changed
  • packages/angular_devkit/build_angular/src/utils/server-rendering

1 file changed

+12
-4
lines changed

packages/angular_devkit/build_angular/src/utils/server-rendering/prerender.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,19 @@ export async function prerenderPages(
3737
warnings: string[];
3838
errors: string[];
3939
}> {
40+
const output: Record<string, string> = {};
41+
const warnings: string[] = [];
42+
const errors: string[] = [];
4043
const allRoutes = await getAllRoutes(tsConfigPath, appShellOptions, prerenderOptions);
44+
45+
if (allRoutes.size < 1) {
46+
return {
47+
errors,
48+
warnings,
49+
output,
50+
};
51+
}
52+
4153
const outputFilesForWorker: Record<string, string> = {};
4254

4355
for (const { text, path } of outputFiles) {
@@ -65,10 +77,6 @@ export async function prerenderPages(
6577
],
6678
});
6779

68-
const output: Record<string, string> = {};
69-
const warnings: string[] = [];
70-
const errors: string[] = [];
71-
7280
try {
7381
const renderingPromises: Promise<void>[] = [];
7482

0 commit comments

Comments
 (0)