Skip to content

Commit 07de060

Browse files
committed
refactor(@angular/ssr): move ɵresetCompiledComponents to destroyAngularServerApp
This change is necessary to prevent NgModule-based rendering from failing with JIT in development mode.
1 parent dff6834 commit 07de060

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

packages/angular/ssr/src/app.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,6 @@ export class AngularServerApp {
168168
);
169169
}
170170

171-
if (typeof ngDevMode === 'undefined' || ngDevMode) {
172-
// Need to clean up GENERATED_COMP_IDS map in `@angular/core`.
173-
// Otherwise an incorrect component ID generation collision detected warning will be displayed in development.
174-
// See: https://github.com/angular/angular-cli/issues/25924
175-
ɵresetCompiledComponents();
176-
}
177-
178171
const { manifest, hooks, assets } = this;
179172

180173
let html = await assets.getIndexServerHtml();
@@ -220,5 +213,12 @@ export function getOrCreateAngularServerApp(): AngularServerApp {
220213
* typically when server configuration or application state needs to be refreshed.
221214
*/
222215
export function destroyAngularServerApp(): void {
216+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
217+
// Need to clean up GENERATED_COMP_IDS map in `@angular/core`.
218+
// Otherwise an incorrect component ID generation collision detected warning will be displayed in development.
219+
// See: https://github.com/angular/angular-cli/issues/25924
220+
ɵresetCompiledComponents();
221+
}
222+
223223
angularServerApp = undefined;
224224
}

packages/angular/ssr/src/routes/ng-routes.ts

-8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
platformCore,
1616
ɵwhenStable as whenStable,
1717
ɵConsole,
18-
ɵresetCompiledComponents,
1918
} from '@angular/core';
2019
import {
2120
INITIAL_CONFIG,
@@ -191,13 +190,6 @@ export async function getRoutesFromAngularRouterConfig(
191190
document: string,
192191
url: URL,
193192
): Promise<AngularRouterConfigResult> {
194-
if (typeof ngDevMode === 'undefined' || ngDevMode) {
195-
// Need to clean up GENERATED_COMP_IDS map in `@angular/core`.
196-
// Otherwise an incorrect component ID generation collision detected warning will be displayed in development.
197-
// See: https://github.com/angular/angular-cli/issues/25924
198-
ɵresetCompiledComponents();
199-
}
200-
201193
const { protocol, host } = url;
202194

203195
// Create and initialize the Angular platform for server-side rendering.

0 commit comments

Comments
 (0)