Skip to content

Commit 52333a7

Browse files
authored
feat: update to angular 19 and typescript 5.7.3, new @deepkit/angular-ssr package (#627)
* feat: update to angular 19 and typescript 5.7.3 feat(type-compiler): add support for typescript 5.7 feat(website): upgraded to new angular 19 ssr chore: upgraded various dependencies * fix(type): invalid test code * chore: fix more tests and improve HttpKernel middleware * feat(type): renamed `createModule` to `createModuleClass` and improve its API BREAKING CHANGE Module name can now be passed in the definition object. Moved the options argument to first argument of `AppModule`. Increase tsconfig target to at least es2020. feat(website): upgrade angular and remove scss * fix(core): test for es2022 * fix(core): make sure Error.cause works even in libraries that have insufficient tsconfig libs loaded * fix: more tests * fix: more tests * fix: more tests * fix: finish website ssr build * feat(angular-ssr): new angular ssr package
1 parent d76f24d commit 52333a7

File tree

323 files changed

+7281
-9329
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

323 files changed

+7281
-9329
lines changed

.yarnrc.yml

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
nodeLinker: node-modules
22

33
yarnPath: .yarn/releases/yarn-4.0.2.cjs
4+
5+
packageExtensions:
6+
7+
dependencies:
8+
"@types/node": "22.13.1"
9+
10+
dependencies:
11+
"@types/node": "22.13.1"
12+
13+
dependencies:
14+
"undici-types": "6.20.0"

examples/rpc-websockets-esm/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"devDependencies": {
1515
"@deepkit/type-compiler": "^1.0.1-alpha.97",
16-
"typescript": "^5.2.2",
16+
"typescript": "~5.7.3",
1717
"ts-node": "^10.9.1"
1818
}
1919
}

examples/rpc-websockets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"devDependencies": {
1414
"@deepkit/type-compiler": "^1.0.1-alpha.97",
15-
"typescript": "^5.2.2",
15+
"typescript": "~5.7.3",
1616
"ts-node": "^10.9.1"
1717
}
1818
}

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"@deepkit/core": "^1.0.1-alpha.143",
3636
"@jest/globals": "^29.2.1",
3737
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
38-
"@types/node": "20.6.0",
38+
"@types/node": "^22.13.1",
3939
"cloc": "^2.7.0",
4040
"codecov": "^3.8.3",
4141
"commitlint": "^18.4.3",
@@ -49,7 +49,7 @@
4949
"ts-node": "^10.9.1",
5050
"ts-node-dev": "^2.0.0",
5151
"typedoc": "^0.23.17",
52-
"typescript": "~5.4.5"
52+
"typescript": "~5.7.3"
5353
},
5454
"engines": {
5555
"node": ">= 20.0.0"
@@ -94,5 +94,5 @@
9494
"packages/topsort"
9595
]
9696
},
97-
"packageManager": "yarn@4.0.2"
97+
"packageManager": "yarn@4.6.0"
9898
}

packages/angular-ssr/.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests

packages/angular-ssr/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

packages/angular-ssr/README.md

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Deepkit + Angular SSR
2+
3+
## Configure Deepkit App
4+
5+
- Make sure to put your main application inside `app.ts` and export the `App` instance:
6+
7+
In `src/server/app.ts`:
8+
9+
```typescript
10+
import { App } from '@deepkit/app';
11+
import { FrameworkModule } from '@deepkit/framework';
12+
import { AngularModule } from '@deepkit/angular-ssr';
13+
14+
export const app = new App({
15+
controllers: [
16+
// your controllers
17+
],
18+
providers: [
19+
// your providers
20+
],
21+
imports: [
22+
new FrameworkModule({}),
23+
new AngularModule()
24+
]
25+
});
26+
```
27+
28+
Create a `src/server/server.ts` and configure it in your `angular.json`:
29+
30+
```json
31+
{
32+
"builder": "@angular-devkit/build-angular:application",
33+
"options": {
34+
"outputPath": "dist/app",
35+
"index": "src/index.html",
36+
"server": "src/main.server.ts",
37+
"outputMode": "server",
38+
"ssr": {
39+
"entry": "src/server/server.ts"
40+
},
41+
"browser": "src/main.ts"
42+
}
43+
}
44+
```
45+
46+
In `src/server/server.ts`:
47+
48+
```typescript
49+
import { app } from './app';
50+
import { RequestHandler } from '@deepkit/angular-ssr';
51+
52+
export const reqHandler = app.get(RequestHandler).create(import.meta.url);
53+
````
54+
55+
## Configure Angular App
56+
57+
In `app/app.config.ts` (client side):
58+
59+
```typescript
60+
@Injectable()
61+
export class APIInterceptor implements HttpInterceptor {
62+
constructor(@Inject('baseUrl') @Optional() private baseUrl: string) {
63+
// In client build, `baseUrl` is empty and should be inferred from the current location.
64+
// If this is not correct, you can simply define the `baseUrl` in the `providers` array of the `appConfig` object.
65+
this.baseUrl = baseUrl || (typeof location !== 'undefined' ? location.origin : '');
66+
}
67+
68+
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
69+
const apiReq = req.clone({ url: `your-api-url/${req.url}` });
70+
return next.handle(apiReq);
71+
}
72+
}
73+
74+
export const appConfig: ApplicationConfig = {
75+
providers: [
76+
{
77+
provide: HTTP_INTERCEPTORS,
78+
useClass: APIInterceptor,
79+
multi: true,
80+
},
81+
// your other providers
82+
],
83+
};
84+
```
85+
86+
In `app/app.server.config.ts` (server side):
87+
88+
```typescript
89+
import { appConfig } from './app.config';
90+
91+
const serverConfig: ApplicationConfig = {
92+
providers: [
93+
provideServerRendering(),
94+
provideServerRouting([
95+
{
96+
path: '**',
97+
renderMode: RenderMode.Server,
98+
},
99+
]),
100+
{
101+
provide: HTTP_TRANSFER_CACHE_ORIGIN_MAP,
102+
deps: [REQUEST_CONTEXT],
103+
useFactory(context: any) {
104+
return { [context?.baseUrl]: context?.publicBaseUrl || '' };
105+
},
106+
},
107+
{
108+
provide: 'baseUrl',
109+
deps: [REQUEST_CONTEXT],
110+
useFactory: (context: any) => {
111+
return context?.baseUrl || '';
112+
},
113+
}
114+
],
115+
};
116+
117+
export const config = mergeApplicationConfig(appConfig, serverConfig);
118+
```

packages/angular-ssr/index.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Deepkit Framework
3+
* Copyright (C) 2021 Deepkit UG, Marc J. Schmidt
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the MIT License.
7+
*
8+
* You should have received a copy of the MIT License along with this program.
9+
*/
10+
11+
export * from './src/angular.js';

packages/angular-ssr/package.json

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "@deepkit/angular-ssr",
3+
"version": "1.0.1-alpha.156",
4+
"description": "Deepkit + angular SSR",
5+
"type": "commonjs",
6+
"main": "./dist/cjs/index.js",
7+
"module": "./dist/esm/index.js",
8+
"types": "./dist/cjs/index.d.ts",
9+
"exports": {
10+
".": {
11+
"types": "./dist/cjs/index.d.ts",
12+
"require": "./dist/cjs/index.js",
13+
"default": "./dist/esm/index.js"
14+
}
15+
},
16+
"sideEffects": false,
17+
"publishConfig": {
18+
"access": "public"
19+
},
20+
"repository": "https://github.com/deepkit/deepkit-framework",
21+
"author": "Marc J. Schmidt <[email protected]>",
22+
"license": "MIT",
23+
"scripts": {
24+
"build": "echo '{\"type\": \"module\"}' > ./dist/esm/package.json"
25+
},
26+
"peerDependencies": {
27+
"@angular/ssr": "^19.1.6",
28+
"@deepkit/app": "^1.0.1-alpha.19",
29+
"@deepkit/http": "^1.0.1-alpha.19"
30+
},
31+
"devDependencies": {
32+
"@angular/ssr": "^19.1.7",
33+
"@deepkit/app": "^1.0.1-alpha.19",
34+
"@deepkit/http": "^1.0.1-alpha.19"
35+
},
36+
"jest": {
37+
"transform": {
38+
"^.+\\.(ts|tsx)$": "ts-jest"
39+
},
40+
"moduleNameMapper": {
41+
"(.+)\\.js": "$1"
42+
},
43+
"testMatch": [
44+
"**/tests/**/*.spec.ts"
45+
]
46+
}
47+
}

0 commit comments

Comments
 (0)