Skip to content

Commit 21549bd

Browse files
committed
fix(@angular-devkit/build-angular): prerender default view when no routes are defined
Prior to the commit, when no routes were defined the default view was not prerendering. Closes #26317 (cherry picked from commit 6cf9342)
1 parent d9f7d43 commit 21549bd

File tree

1 file changed

+8
-3
lines changed
  • packages/angular_devkit/build_angular/src/utils/routes-extractor

1 file changed

+8
-3
lines changed

packages/angular_devkit/build_angular/src/utils/routes-extractor/extractor.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,15 @@ export async function* extractRoutes(
117117

118118
const injector = applicationRef.injector;
119119
const router = injector.get(Router);
120-
const compiler = injector.get(Compiler);
121120

122-
// Extract all the routes from the config.
123-
yield* getRoutesFromRouterConfig(router.config, compiler, injector);
121+
if (router.config.length === 0) {
122+
// In case there are no routes available
123+
yield { route: '', success: true, redirect: false };
124+
} else {
125+
const compiler = injector.get(Compiler);
126+
// Extract all the routes from the config.
127+
yield* getRoutesFromRouterConfig(router.config, compiler, injector);
128+
}
124129
} finally {
125130
platformRef.destroy();
126131
}

0 commit comments

Comments
 (0)