Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 81b5da0

Browse files
committed
test: use new ssr setup
1 parent 52eb431 commit 81b5da0

File tree

7 files changed

+33
-56
lines changed

7 files changed

+33
-56
lines changed

apps/ssr/src/app/app.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
import { isPlatformServer } from '@angular/common';
22
import { Component, Inject, NgZone, OnInit, PLATFORM_ID } from '@angular/core';
33
import { rxState } from '@rx-angular/state';
4+
import { RxFor } from '@rx-angular/template/for';
5+
import { RxLet } from '@rx-angular/template/let';
6+
import { RxPush } from '@rx-angular/template/push';
7+
import { RxUnpatch } from '@rx-angular/template/unpatch';
48
import { of } from 'rxjs';
59

610
@Component({
711
selector: 'rx-angular-root',
12+
standalone: true,
813
template: `
914
<div id="let" *rxLet="color$; let color">{{ color }}</div>
1015
<div id="push">{{ color$ | push }}</div>
1116
<div id="unpatch" [unpatch]="['click']" (click)="onClick()"></div>
1217
<div class="for" *rxFor="let color of colors$">{{ color }}</div>
1318
`,
19+
imports: [RxPush, RxLet, RxUnpatch, RxFor],
1420
})
1521
export class AppComponent implements OnInit {
1622
private readonly state = rxState<{ color: string; colors: string[] }>(

apps/ssr/src/app/app.config.server.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
2+
import { provideServerRendering } from '@angular/platform-server';
3+
import { appConfig } from './app.config';
4+
5+
const serverConfig: ApplicationConfig = {
6+
providers: [provideServerRendering()],
7+
};
8+
9+
export const config = mergeApplicationConfig(appConfig, serverConfig);

apps/ssr/src/app/app.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { ApplicationConfig } from '@angular/core';
2+
3+
import { provideClientHydration } from '@angular/platform-browser';
4+
5+
export const appConfig: ApplicationConfig = {
6+
providers: [provideClientHydration()],
7+
};

apps/ssr/src/app/app.module.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

apps/ssr/src/app/app.server.module.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

apps/ssr/src/main.server.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import { enableProdMode } from '@angular/core';
1+
import { bootstrapApplication } from '@angular/platform-browser';
2+
import { AppComponent } from './app/app.component';
3+
import { config } from './app/app.config.server';
24

3-
import { environment } from './environments/environment';
5+
const bootstrap = () => bootstrapApplication(AppComponent, config);
46

5-
if (environment.production) {
6-
enableProdMode();
7-
}
8-
9-
export { AppServerModule } from './app/app.server.module';
7+
export default bootstrap;

apps/ssr/src/main.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
import { enableProdMode } from '@angular/core';
2-
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
1+
import { bootstrapApplication } from '@angular/platform-browser';
2+
import { appConfig } from './app/app.config';
3+
import { AppComponent } from './app/app.component';
34

4-
import { AppModule } from './app/app.module';
5-
import { environment } from './environments/environment';
6-
7-
if (environment.production) {
8-
enableProdMode();
9-
}
10-
11-
document.addEventListener('DOMContentLoaded', () => {
12-
platformBrowserDynamic()
13-
.bootstrapModule(AppModule)
14-
.catch((err) => console.error(err));
15-
});
5+
bootstrapApplication(AppComponent, appConfig).catch((err) =>
6+
console.error(err)
7+
);

0 commit comments

Comments
 (0)