Skip to content

Commit f2edaaf

Browse files
committed
refactor(@angular/ssr): remove circular dependency between app.ts and manifest.ts
Updated `EntryPointExports` interface to avoid a circular dependency between `app.ts` and `manifest.ts`.
1 parent 30c25bf commit f2edaaf

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

goldens/circular-deps/packages.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,5 @@
2323
[
2424
"packages/angular/cli/src/analytics/analytics.ts",
2525
"packages/angular/cli/src/command-builder/command-module.ts"
26-
],
27-
[
28-
"packages/angular/ssr/src/app.ts",
29-
"packages/angular/ssr/src/assets.ts",
30-
"packages/angular/ssr/src/manifest.ts"
3126
]
3227
]

packages/angular/ssr/src/app-engine.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9+
import type { AngularServerApp } from './app';
910
import { Hooks } from './hooks';
1011
import { getPotentialLocaleIdFromUrl } from './i18n';
1112
import { EntryPointExports, getAngularAppEngineManifest } from './manifest';
@@ -89,7 +90,10 @@ export class AngularAppEngine implements AngularServerAppManager {
8990
}
9091

9192
const { ɵgetOrCreateAngularServerApp: getOrCreateAngularServerApp } = await entryPoint();
92-
const serverApp = getOrCreateAngularServerApp();
93+
// Note: Using `instanceof` is not feasible here because `AngularServerApp` will
94+
// be located in separate bundles, making `instanceof` checks unreliable.
95+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
96+
const serverApp = getOrCreateAngularServerApp() as AngularServerApp;
9397
serverApp.hooks = this.hooks;
9498

9599
return serverApp.render(request, requestContext);

packages/angular/ssr/src/manifest.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import type { destroyAngularServerApp, getOrCreateAngularServerApp } from './app';
109
import type { SerializableRouteTreeNode } from './routes/route-tree';
1110
import { AngularBootstrap } from './utils/ng';
1211

@@ -16,13 +15,15 @@ import { AngularBootstrap } from './utils/ng';
1615
export interface EntryPointExports {
1716
/**
1817
* A reference to the function that creates an Angular server application instance.
18+
*
19+
* @note The return type is `unknown` to prevent circular dependency issues.
1920
*/
20-
ɵgetOrCreateAngularServerApp: typeof getOrCreateAngularServerApp;
21+
ɵgetOrCreateAngularServerApp: () => unknown;
2122

2223
/**
2324
* A reference to the function that destroys the `AngularServerApp` instance.
2425
*/
25-
ɵdestroyAngularServerApp: typeof destroyAngularServerApp;
26+
ɵdestroyAngularServerApp: () => void;
2627
}
2728

2829
/**

0 commit comments

Comments
 (0)