@nx/angular 0.0.0-pr-30516-94d09ba → 0.0.0-pr-30756-ba621b6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/migrations.json CHANGED
@@ -1666,6 +1666,15 @@
1666
1666
  "alwaysAddToPackageJson": false
1667
1667
  }
1668
1668
  }
1669
+ },
1670
+ "20.8.1": {
1671
+ "version": "20.8.1-beta.0",
1672
+ "packages": {
1673
+ "@nx/angular-rspack": {
1674
+ "version": "^20.7.0",
1675
+ "alwaysAddToPackageJson": false
1676
+ }
1677
+ }
1669
1678
  }
1670
1679
  }
1671
1680
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "0.0.0-pr-30516-94d09ba",
3
+ "version": "0.0.0-pr-30756-ba621b6",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, Playwright and Cypress. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
@@ -72,14 +72,14 @@
72
72
  "semver": "^7.5.3",
73
73
  "tslib": "^2.3.0",
74
74
  "webpack-merge": "^5.8.0",
75
- "@nx/devkit": "0.0.0-pr-30516-94d09ba",
76
- "@nx/js": "0.0.0-pr-30516-94d09ba",
77
- "@nx/eslint": "0.0.0-pr-30516-94d09ba",
78
- "@nx/webpack": "0.0.0-pr-30516-94d09ba",
79
- "@nx/rspack": "0.0.0-pr-30516-94d09ba",
80
- "@nx/module-federation": "0.0.0-pr-30516-94d09ba",
81
- "@nx/web": "0.0.0-pr-30516-94d09ba",
82
- "@nx/workspace": "0.0.0-pr-30516-94d09ba",
75
+ "@nx/devkit": "0.0.0-pr-30756-ba621b6",
76
+ "@nx/js": "0.0.0-pr-30756-ba621b6",
77
+ "@nx/eslint": "0.0.0-pr-30756-ba621b6",
78
+ "@nx/webpack": "0.0.0-pr-30756-ba621b6",
79
+ "@nx/rspack": "0.0.0-pr-30756-ba621b6",
80
+ "@nx/module-federation": "0.0.0-pr-30756-ba621b6",
81
+ "@nx/web": "0.0.0-pr-30756-ba621b6",
82
+ "@nx/workspace": "0.0.0-pr-30756-ba621b6",
83
83
  "piscina": "^4.4.0"
84
84
  },
85
85
  "peerDependencies": {
@@ -76,6 +76,12 @@ async function applicationGenerator(tree, schema) {
76
76
  skipInstall: options.skipPackageJson,
77
77
  skipFormat: true,
78
78
  });
79
+ if (options.ssr) {
80
+ (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, './files/rspack-ssr'), options.appProjectSourceRoot, {
81
+ pathToDistFolder: (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(options.appProjectRoot), options.outputPath, 'browser'),
82
+ tmpl: '',
83
+ });
84
+ }
79
85
  }
80
86
  if (!options.skipFormat) {
81
87
  await (0, devkit_1.formatFiles)(tree);
@@ -0,0 +1,72 @@
1
+ import 'zone.js/node';
2
+
3
+ import { APP_BASE_HREF } from '@angular/common';
4
+ import { CommonEngine } from '@angular/ssr/node';
5
+ import * as express from 'express';
6
+ import { existsSync } from 'node:fs';
7
+ import { join } from 'node:path';
8
+ import bootstrap from './main.server';
9
+
10
+ // The Express app is exported so that it can be used by serverless Functions.
11
+ export function app(): express.Express {
12
+ const server = express();
13
+ const distFolder = join(process.cwd(), "<%= pathToDistFolder %>");
14
+ const indexHtml = existsSync(join(distFolder, 'index.original.html'))
15
+ ? join(distFolder, 'index.original.html')
16
+ : join(distFolder, 'index.html');
17
+
18
+ const commonEngine = new CommonEngine();
19
+
20
+ server.set('view engine', 'html');
21
+ server.set('views', distFolder);
22
+
23
+ // Example Express Rest API endpoints
24
+ // server.get('/api/**', (req, res) => { });
25
+ // Serve static files from /browser
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;
36
+
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));
47
+ });
48
+
49
+ return server;
50
+ }
51
+
52
+ function run(): void {
53
+ const port = process.env['PORT'] || 4000;
54
+
55
+ // Start up the Node server
56
+ const server = app();
57
+ server.listen(port, () => {
58
+ console.log(`Node Express server listening on http://localhost:${port}`);
59
+ });
60
+ }
61
+
62
+ // Webpack will replace 'require' with '__webpack_require__'
63
+ // '__non_webpack_require__' is a proxy to Node 'require'
64
+ // The below code is to ensure that the server is run only when not requiring the bundle.
65
+ declare const __non_webpack_require__: NodeRequire;
66
+ const mainModule = __non_webpack_require__.main;
67
+ const moduleFilename = (mainModule && mainModule.filename) || '';
68
+ if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
69
+ run();
70
+ }
71
+
72
+ export default bootstrap;
@@ -14,7 +14,9 @@ const enquirer_1 = require("enquirer");
14
14
  const SUPPORTED_EXECUTORS = [
15
15
  '@angular-devkit/build-angular:browser',
16
16
  '@angular-devkit/build-angular:dev-server',
17
+ '@angular-devkit/build-angular:server',
17
18
  '@nx/angular:webpack-browser',
19
+ '@nx/angular:webpack-server',
18
20
  '@nx/angular:dev-server',
19
21
  '@nx/angular:module-federation-dev-server',
20
22
  ];
@@ -22,21 +24,7 @@ const RENAMED_OPTIONS = {
22
24
  main: 'browser',
23
25
  ngswConfigPath: 'serviceWorker',
24
26
  };
25
- const REMOVED_OPTIONS = [
26
- 'publicHost',
27
- 'disableHostCheck',
28
- 'resourcesOutputPath',
29
- 'routesFile',
30
- 'routes',
31
- 'discoverRoutes',
32
- 'appModuleBundle',
33
- 'inputIndexPath',
34
- 'outputIndexPath',
35
- 'buildOptimizer',
36
- 'deployUrl',
37
- 'buildTarget',
38
- 'browserTarget',
39
- ];
27
+ const REMOVED_OPTIONS = ['buildOptimizer', 'buildTarget', 'browserTarget'];
40
28
  function normalizeFromProjectRoot(tree, path, projectRoot) {
41
29
  if (projectRoot === '.') {
42
30
  if (!path.startsWith('./')) {
@@ -268,6 +256,13 @@ async function convertToRspack(tree, schema) {
268
256
  }
269
257
  buildTargetNames.push(targetName);
270
258
  }
259
+ else if (target.executor === '@angular-devkit/build-angular:server' ||
260
+ target.executor === '@nx/angular:webpack-server') {
261
+ createConfigOptions.ssr ??= {};
262
+ createConfigOptions.ssr.entry ??= normalizeFromProjectRoot(tree, target.options.main, project.root);
263
+ createConfigOptions.server = './src/main.server.ts';
264
+ buildTargetNames.push(targetName);
265
+ }
271
266
  else if (target.executor === '@angular-devkit/build-angular:dev-server' ||
272
267
  target.executor === '@nx/angular:dev-server' ||
273
268
  target.executor === '@nx/angular:module-federation-dev-server') {
@@ -2,7 +2,7 @@ export declare const nxVersion: any;
2
2
  export declare const angularVersion = "~19.2.0";
3
3
  export declare const angularDevkitVersion = "~19.2.0";
4
4
  export declare const ngPackagrVersion = "~19.2.0";
5
- export declare const angularRspackVersion = "~20.6.1";
5
+ export declare const angularRspackVersion = "^20.7.0";
6
6
  export declare const ngrxVersion = "^19.0.0";
7
7
  export declare const rxjsVersion = "~7.8.0";
8
8
  export declare const zoneJsVersion = "~0.15.0";
@@ -5,7 +5,7 @@ exports.nxVersion = require('../../package.json').version;
5
5
  exports.angularVersion = '~19.2.0';
6
6
  exports.angularDevkitVersion = '~19.2.0';
7
7
  exports.ngPackagrVersion = '~19.2.0';
8
- exports.angularRspackVersion = '~20.6.1';
8
+ exports.angularRspackVersion = '^20.7.0';
9
9
  exports.ngrxVersion = '^19.0.0';
10
10
  exports.rxjsVersion = '~7.8.0';
11
11
  exports.zoneJsVersion = '~0.15.0';