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

Skip to content

Commit e833a4e

Browse files
committed
chore: migrate to Angular v17
1 parent b3202a7 commit e833a4e

File tree

15 files changed

+1482
-2415
lines changed

15 files changed

+1482
-2415
lines changed

apps/demos/project.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,32 +90,31 @@
9090
"serve": {
9191
"executor": "@angular-devkit/build-angular:dev-server",
9292
"options": {
93-
"browserTarget": "demos:build",
94-
"port": 4300
93+
"port": 4300,
94+
"buildTarget": "demos:build"
9595
},
9696
"configurations": {
9797
"production": {
98-
"browserTarget": "demos:build:production"
98+
"buildTarget": "demos:build:production"
9999
},
100100
"npm": {
101-
"browserTarget": "demos:build:npm"
101+
"buildTarget": "demos:build:npm"
102102
},
103103
"zoneless": {
104-
"browserTarget": "demos:build:zoneless"
104+
"buildTarget": "demos:build:zoneless"
105105
}
106106
}
107107
},
108108
"extract-i18n": {
109109
"executor": "@angular-devkit/build-angular:extract-i18n",
110110
"options": {
111-
"browserTarget": "demos:build"
111+
"buildTarget": "demos:build"
112112
}
113113
},
114114
"test": {
115115
"executor": "@nx/jest:jest",
116116
"options": {
117-
"jestConfig": "apps/demos/jest.config.ts",
118-
"passWithNoTests": true
117+
"jestConfig": "apps/demos/jest.config.ts"
119118
},
120119
"outputs": ["{workspaceRoot}/coverage/apps/demos"]
121120
}

apps/demos/src/app/features/home/home.component.ts

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,41 @@ import { Component } from '@angular/core';
44
selector: 'rxa-home',
55
template: `
66
<h1>Welcome to RxAngular Demos!</h1>
7-
<h3>Explore various sections that will guide you through features of RxAngular.</h3>
7+
<h3>
8+
Explore various sections that will guide you through features of
9+
RxAngular.
10+
</h3>
811
912
<ul>
1013
<li><h4>🏁 Fundamentals</h4></li>
11-
Demos presenting fundamental rules and functionalities existing in Angular that are good to know before you start your journey with RxAngular.
14+
Demos presenting fundamental rules and functionalities existing in Angular
15+
that are good to know before you start your journey with RxAngular.
1216
1317
<li><h4>🧰 Template</h4></li>
14-
Playground for different functionalities of the <code>@rx-angular/template</code> package.
18+
Playground for different functionalities of the
19+
<code>&#64;rx-angular/template</code>
20+
package.
1521
1622
<li><h4>📋 Tutorials</h4></li>
17-
Tutorials for features existing in the <code>@rx-angular</code> packages.
23+
Tutorials for features existing in the
24+
<code>&#64;rx-angular</code>
25+
packages.
1826
1927
<li><h4>🧮 Integrations</h4></li>
20-
<code>@rx-angular/state</code> integrated with different libraries and patterns.
28+
<code>&#64;rx-angular/state</code>
29+
integrated with different libraries and patterns.
2130
2231
<li><h4>🔬 Experiments</h4></li>
23-
Experiments with features, that are still under development. ⚠️Warning! ⚠️Unstable or broken features may lay ahead!
32+
Experiments with features, that are still under development. ⚠️Warning!
33+
⚠️Unstable or broken features may lay ahead!
2434
</ul>
2535
`,
26-
styles: [`
27-
code {
28-
background: black;
29-
}
30-
`]
36+
styles: [
37+
`
38+
code {
39+
background: black;
40+
}
41+
`,
42+
],
3143
})
3244
export class HomeComponent {}

apps/ssr/project.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,25 @@
5656
"serve": {
5757
"executor": "@angular-devkit/build-angular:dev-server",
5858
"options": {
59-
"browserTarget": "ssr:build"
59+
"buildTarget": "ssr:build"
6060
},
6161
"configurations": {
6262
"production": {
63-
"browserTarget": "ssr:build:production"
63+
"buildTarget": "ssr:build:production"
6464
}
6565
}
6666
},
6767
"extract-i18n": {
6868
"executor": "@angular-devkit/build-angular:extract-i18n",
6969
"options": {
70-
"browserTarget": "ssr:build"
70+
"buildTarget": "ssr:build"
7171
}
7272
},
7373
"test": {
7474
"executor": "@nx/jest:jest",
7575
"outputs": ["{workspaceRoot}/coverage/apps/ssr"],
7676
"options": {
77-
"jestConfig": "apps/ssr/jest.config.ts",
78-
"passWithNoTests": true
77+
"jestConfig": "apps/ssr/jest.config.ts"
7978
}
8079
},
8180
"server": {
@@ -102,7 +101,7 @@
102101
}
103102
},
104103
"serve-ssr": {
105-
"executor": "@nguniversal/builders:ssr-dev-server",
104+
"executor": "@angular-devkit/build-angular:ssr-dev-server",
106105
"options": {
107106
"browserTarget": "ssr:build",
108107
"serverTarget": "ssr:server"

apps/ssr/server.ts

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,56 @@
11
import 'zone.js/node';
22

3-
import { ngExpressEngine } from '@nguniversal/express-engine';
4-
import * as express from 'express';
5-
import { join } from 'path';
6-
7-
import { AppServerModule } from './src/main.server';
83
import { APP_BASE_HREF } from '@angular/common';
9-
import { existsSync } from 'fs';
4+
import { CommonEngine } from '@angular/ssr';
5+
import * as express from 'express';
6+
import { existsSync } from 'node:fs';
7+
import { join } from 'node:path';
8+
import bootstrap from './src/main.server';
109

1110
// The Express app is exported so that it can be used by serverless Functions.
1211
export function app(): express.Express {
1312
const server = express();
1413
const distFolder = join(process.cwd(), 'dist/apps/ssr/browser');
15-
const indexHtml = existsSync(join(distFolder, 'index.original.html')) ? 'index.original.html' : 'index';
14+
const indexHtml = existsSync(join(distFolder, 'index.original.html'))
15+
? join(distFolder, 'index.original.html')
16+
: join(distFolder, 'index.html');
1617

17-
// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
18-
server.engine('html', ngExpressEngine({
19-
bootstrap: AppServerModule,
20-
}));
18+
const commonEngine = new CommonEngine();
2119

2220
server.set('view engine', 'html');
2321
server.set('views', distFolder);
2422

2523
// Example Express Rest API endpoints
2624
// server.get('/api/**', (req, res) => { });
2725
// Serve static files from /browser
28-
server.get('*.*', express.static(distFolder, {
29-
maxAge: '1y'
30-
}));
26+
server.get(
27+
'*.*',
28+
express.static(distFolder, {
29+
maxAge: '1y',
30+
})
31+
);
32+
33+
// All regular routes use the Angular engine
34+
server.get('*', (req, res, next) => {
35+
const { protocol, originalUrl, baseUrl, headers } = req;
3136

32-
// All regular routes use the Universal engine
33-
server.get('*', (req, res) => {
34-
res.render(indexHtml, { req, providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }] });
37+
commonEngine
38+
.render({
39+
bootstrap,
40+
documentFilePath: indexHtml,
41+
url: `${protocol}://${headers.host}${originalUrl}`,
42+
publicPath: distFolder,
43+
providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }],
44+
})
45+
.then((html) => res.send(html))
46+
.catch((err) => next(err));
3547
});
3648

3749
return server;
3850
}
3951

4052
function run(): void {
41-
const port = process.env.PORT || 4000;
53+
const port = process.env['PORT'] || 4000;
4254

4355
// Start up the Node server
4456
const server = app();
@@ -52,9 +64,9 @@ function run(): void {
5264
// The below code is to ensure that the server is run only when not requiring the bundle.
5365
declare const __non_webpack_require__: NodeRequire;
5466
const mainModule = __non_webpack_require__.main;
55-
const moduleFilename = mainModule && mainModule.filename || '';
67+
const moduleFilename = (mainModule && mainModule.filename) || '';
5668
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
5769
run();
5870
}
5971

60-
export * from './src/main.server';
72+
export default bootstrap;

apps/ssr/server.ts.bak

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import 'zone.js/node';
2+
3+
import { ngExpressEngine } from '@nguniversal/express-engine';
4+
import * as express from 'express';
5+
import { join } from 'path';
6+
7+
import { AppServerModule } from './src/main.server';
8+
import { APP_BASE_HREF } from '@angular/common';
9+
import { existsSync } from 'fs';
10+
11+
// The Express app is exported so that it can be used by serverless Functions.
12+
export function app(): express.Express {
13+
const server = express();
14+
const distFolder = join(process.cwd(), 'dist/apps/ssr/browser');
15+
const indexHtml = existsSync(join(distFolder, 'index.original.html')) ? 'index.original.html' : 'index';
16+
17+
// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
18+
server.engine('html', ngExpressEngine({
19+
bootstrap: AppServerModule,
20+
}));
21+
22+
server.set('view engine', 'html');
23+
server.set('views', distFolder);
24+
25+
// Example Express Rest API endpoints
26+
// server.get('/api/**', (req, res) => { });
27+
// Serve static files from /browser
28+
server.get('*.*', express.static(distFolder, {
29+
maxAge: '1y'
30+
}));
31+
32+
// All regular routes use the Universal engine
33+
server.get('*', (req, res) => {
34+
res.render(indexHtml, { req, providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }] });
35+
});
36+
37+
return server;
38+
}
39+
40+
function run(): void {
41+
const port = process.env.PORT || 4000;
42+
43+
// Start up the Node server
44+
const server = app();
45+
server.listen(port, () => {
46+
console.log(`Node Express server listening on http://localhost:${port}`);
47+
});
48+
}
49+
50+
// Webpack will replace 'require' with '__webpack_require__'
51+
// '__non_webpack_require__' is a proxy to Node 'require'
52+
// The below code is to ensure that the server is run only when not requiring the bundle.
53+
declare const __non_webpack_require__: NodeRequire;
54+
const mainModule = __non_webpack_require__.main;
55+
const moduleFilename = mainModule && mainModule.filename || '';
56+
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
57+
run();
58+
}
59+
60+
export * from './src/main.server';

apps/vanilla-case-studies/project.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,24 @@
6262
"serve": {
6363
"executor": "@angular-devkit/build-angular:dev-server",
6464
"options": {
65-
"browserTarget": "vanilla-case-studies:build"
65+
"buildTarget": "vanilla-case-studies:build"
6666
},
6767
"configurations": {
6868
"production": {
69-
"browserTarget": "vanilla-case-studies:build:production"
69+
"buildTarget": "vanilla-case-studies:build:production"
7070
}
7171
}
7272
},
7373
"extract-i18n": {
7474
"executor": "@angular-devkit/build-angular:extract-i18n",
7575
"options": {
76-
"browserTarget": "vanilla-case-studies:build"
76+
"buildTarget": "vanilla-case-studies:build"
7777
}
7878
},
7979
"test": {
8080
"executor": "@nx/jest:jest",
8181
"options": {
82-
"jestConfig": "apps/vanilla-case-studies/jest.config.ts",
83-
"passWithNoTests": true
82+
"jestConfig": "apps/vanilla-case-studies/jest.config.ts"
8483
},
8584
"outputs": ["{workspaceRoot}/coverage/apps/vanilla-case-studies"]
8685
}

libs/cdk/project.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"executor": "@nx/jest:jest",
3333
"options": {
3434
"jestConfig": "libs/cdk/jest.config.ts",
35-
"passWithNoTests": true,
3635
"codeCoverage": true
3736
},
3837
"outputs": ["{workspaceRoot}/coverage/cdk"]

libs/eslint-plugin/project.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
"executor": "@nx/jest:jest",
1616
"outputs": ["{workspaceRoot}/coverage/eslint-plugin"],
1717
"options": {
18-
"jestConfig": "libs/eslint-plugin/jest.config.ts",
19-
"passWithNoTests": true
18+
"jestConfig": "libs/eslint-plugin/jest.config.ts"
2019
}
2120
},
2221
"build": {

libs/isr/project.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"outputs": ["{workspaceRoot}/coverage/isr"],
2727
"options": {
2828
"jestConfig": "libs/isr/jest.config.ts",
29-
"passWithNoTests": true,
3029
"codeCoverage": true
3130
}
3231
},

libs/state/project.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"executor": "@nx/jest:jest",
3434
"options": {
3535
"jestConfig": "libs/state/jest.config.ts",
36-
"passWithNoTests": true,
3736
"codeCoverage": true
3837
},
3938
"outputs": ["{workspaceRoot}/coverage/state"]

libs/template/project.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"executor": "@nx/jest:jest",
3434
"options": {
3535
"jestConfig": "libs/template/jest.config.ts",
36-
"passWithNoTests": true,
3736
"codeCoverage": true
3837
},
3938
"outputs": ["{workspaceRoot}/coverage/template"]

libs/test-helpers/project.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
"test": {
2525
"executor": "@nx/jest:jest",
2626
"options": {
27-
"jestConfig": "libs/test-helpers/jest.config.ts",
28-
"passWithNoTests": true
27+
"jestConfig": "libs/test-helpers/jest.config.ts"
2928
},
3029
"outputs": ["{workspaceRoot}/coverage/${projectRoot}"]
3130
},

nx.json

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@
6060
"inputs": ["default", "^production"],
6161
"cache": true
6262
},
63-
"test": {
64-
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
65-
"cache": true
66-
},
6763
"lint": {
6864
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"],
6965
"cache": true
@@ -75,11 +71,21 @@
7571
"publish": {
7672
"dependsOn": ["lint", "test", "version", "build"]
7773
},
78-
"build-schematics": {
79-
"cache": true
80-
},
8174
"build-lib": {
8275
"cache": true
76+
},
77+
"@nx/jest:jest": {
78+
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
79+
"cache": true,
80+
"options": {
81+
"passWithNoTests": true
82+
},
83+
"configurations": {
84+
"ci": {
85+
"ci": true,
86+
"codeCoverage": true
87+
}
88+
}
8389
}
8490
},
8591
"nxCloudAccessToken": "OTg2OGFkNmMtNzA5Zi00MjBiLWFhMmQtOGYwNTQ1MjM1ZjQ3fHJlYWQtd3JpdGU=",

0 commit comments

Comments
 (0)