@nx/angular 19.6.0-canary.20240814-6d83ae2 → 19.6.0-rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. package/executors.d.ts +1 -1
  2. package/executors.js +1 -1
  3. package/executors.json +5 -5
  4. package/migrations.json +76 -0
  5. package/package.json +8 -8
  6. package/src/executors/module-federation-ssr-dev-server/lib/build-static-remotes.d.ts +4 -0
  7. package/src/executors/module-federation-ssr-dev-server/lib/build-static-remotes.js +65 -0
  8. package/src/executors/module-federation-ssr-dev-server/lib/normalize-options.d.ts +2 -0
  9. package/src/executors/module-federation-ssr-dev-server/lib/normalize-options.js +19 -0
  10. package/src/executors/module-federation-ssr-dev-server/lib/start-dev-remotes.d.ts +5 -0
  11. package/src/executors/module-federation-ssr-dev-server/lib/start-dev-remotes.js +30 -0
  12. package/src/executors/module-federation-ssr-dev-server/lib/start-static-remotes.d.ts +9 -0
  13. package/src/executors/module-federation-ssr-dev-server/lib/start-static-remotes.js +37 -0
  14. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +4 -0
  15. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +101 -0
  16. package/src/{builders/module-federation-dev-ssr → executors/module-federation-ssr-dev-server}/schema.d.ts +7 -1
  17. package/src/{builders/module-federation-dev-ssr → executors/module-federation-ssr-dev-server}/schema.json +34 -2
  18. package/src/executors/utilities/esbuild-extensions.d.ts +2 -1
  19. package/src/generators/component-cypress-spec/schema.json +2 -1
  20. package/src/generators/host/files/js/webpack.server.config.js__tmpl__ +6 -1
  21. package/src/generators/host/files/ts/webpack.server.config.ts__tmpl__ +6 -1
  22. package/src/generators/remote/files/base/webpack.server.config.js__tmpl__ +7 -1
  23. package/src/generators/remote/files/base-ts/webpack.server.config.ts__tmpl__ +6 -1
  24. package/src/generators/setup-mf/files/ts-webpack/webpack.config.ts__tmpl__ +6 -1
  25. package/src/generators/setup-mf/files/ts-webpack/webpack.prod.config.ts__tmpl__ +6 -1
  26. package/src/generators/setup-mf/files/webpack/webpack.config.js__tmpl__ +7 -1
  27. package/src/generators/setup-mf/files/webpack/webpack.prod.config.js__tmpl__ +7 -1
  28. package/src/generators/stories/schema.json +4 -2
  29. package/src/migrations/update-19-6-0/turn-off-dts-by-default.d.ts +2 -0
  30. package/src/migrations/update-19-6-0/turn-off-dts-by-default.js +56 -0
  31. package/src/migrations/update-19-6-0/update-angular-cli.d.ts +3 -0
  32. package/src/migrations/update-19-6-0/update-angular-cli.js +23 -0
  33. package/src/utils/versions.d.ts +3 -3
  34. package/src/utils/versions.js +3 -3
  35. package/src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl.d.ts +0 -4
  36. package/src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl.js +0 -103
package/executors.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export * from './src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl';
2
1
  export * from './src/builders/webpack-browser/webpack-browser.impl';
3
2
  export * from './src/builders/webpack-server/webpack-server.impl';
4
3
  export * from './src/executors/module-federation-dev-server/module-federation-dev-server.impl';
@@ -8,6 +7,7 @@ export * from './src/executors/package/package.impl';
8
7
  export * from './src/executors/browser-esbuild/browser-esbuild.impl';
9
8
  export * from './src/executors/application/application.impl';
10
9
  export * from './src/executors/extract-i18n/extract-i18n.impl';
10
+ export * from './src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl';
11
11
  import { executeDevServerBuilder } from './src/builders/dev-server/dev-server.impl';
12
12
  export {
13
13
  /**
package/executors.js CHANGED
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeDevServerBuilder = exports.executeWebpackDevServerBuilder = void 0;
4
4
  const tslib_1 = require("tslib");
5
- tslib_1.__exportStar(require("./src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl"), exports);
6
5
  tslib_1.__exportStar(require("./src/builders/webpack-browser/webpack-browser.impl"), exports);
7
6
  tslib_1.__exportStar(require("./src/builders/webpack-server/webpack-server.impl"), exports);
8
7
  tslib_1.__exportStar(require("./src/executors/module-federation-dev-server/module-federation-dev-server.impl"), exports);
@@ -12,6 +11,7 @@ tslib_1.__exportStar(require("./src/executors/package/package.impl"), exports);
12
11
  tslib_1.__exportStar(require("./src/executors/browser-esbuild/browser-esbuild.impl"), exports);
13
12
  tslib_1.__exportStar(require("./src/executors/application/application.impl"), exports);
14
13
  tslib_1.__exportStar(require("./src/executors/extract-i18n/extract-i18n.impl"), exports);
14
+ tslib_1.__exportStar(require("./src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl"), exports);
15
15
  const dev_server_impl_1 = require("./src/builders/dev-server/dev-server.impl");
16
16
  Object.defineProperty(exports, "executeWebpackDevServerBuilder", { enumerable: true, get: function () { return dev_server_impl_1.executeDevServerBuilder; } });
17
17
  Object.defineProperty(exports, "executeDevServerBuilder", { enumerable: true, get: function () { return dev_server_impl_1.executeDevServerBuilder; } });
package/executors.json CHANGED
@@ -25,6 +25,11 @@
25
25
  "schema": "./src/executors/module-federation-dev-server/schema.json",
26
26
  "description": "Serves host [Module Federation](https://module-federation.io/) applications ([webpack](https://webpack.js.org/)-based) allowing to specify which remote applications should be served with the host."
27
27
  },
28
+ "module-federation-dev-ssr": {
29
+ "implementation": "./src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl",
30
+ "schema": "./src/executors/module-federation-ssr-dev-server/schema.json",
31
+ "description": "The module-federation-ssr-dev-server executor is reserved exclusively for use with host SSR Module Federation applications. It allows the user to specify which remote applications should be served with the host."
32
+ },
28
33
  "application": {
29
34
  "implementation": "./src/executors/application/application.impl",
30
35
  "schema": "./src/executors/application/schema.json",
@@ -51,11 +56,6 @@
51
56
  "implementation": "./src/builders/webpack-server/webpack-server.impl",
52
57
  "schema": "./src/builders/webpack-server/schema.json",
53
58
  "description": "Builds a server Angular application using [webpack](https://webpack.js.org/). This executor is a drop-in replacement for the `@angular-devkit/build-angular:server` builder provided by the Angular CLI. It is usually used in tandem with the `@nx/angular:webpack-browser` executor when your Angular application uses a custom webpack configuration."
54
- },
55
- "module-federation-dev-ssr": {
56
- "implementation": "./src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl",
57
- "schema": "./src/builders/module-federation-dev-ssr/schema.json",
58
- "description": "Serves host [Module Federation](https://module-federation.io/) applications ([webpack](https://webpack.js.org/)-based) that use SSR allowing to specify which remote applications should be served with the host."
59
59
  }
60
60
  }
61
61
  }
package/migrations.json CHANGED
@@ -413,6 +413,21 @@
413
413
  },
414
414
  "description": "Update the @angular/cli package version to ~18.1.0.",
415
415
  "factory": "./src/migrations/update-19-5-0/update-angular-cli"
416
+ },
417
+ "update-19-6-0": {
418
+ "cli": "nx",
419
+ "version": "19.6.0-beta.4",
420
+ "description": "Ensure Module Federation DTS is turned off by default.",
421
+ "factory": "./src/migrations/update-19-6-0/turn-off-dts-by-default"
422
+ },
423
+ "update-angular-cli-version-18-2-0": {
424
+ "cli": "nx",
425
+ "version": "19.6.0-beta.7",
426
+ "requires": {
427
+ "@angular/core": ">=18.2.0"
428
+ },
429
+ "description": "Update the @angular/cli package version to ~18.2.0.",
430
+ "factory": "./src/migrations/update-19-6-0/update-angular-cli"
416
431
  }
417
432
  },
418
433
  "packageJsonUpdates": {
@@ -2028,6 +2043,67 @@
2028
2043
  "alwaysAddToPackageJson": false
2029
2044
  }
2030
2045
  }
2046
+ },
2047
+ "19.6.0": {
2048
+ "version": "19.6.0-beta.7",
2049
+ "x-prompt": "Do you want to update the Angular version to v18.2?",
2050
+ "requires": {
2051
+ "@angular/core": ">=18.1.0 <18.2.0"
2052
+ },
2053
+ "packages": {
2054
+ "@angular-devkit/build-angular": {
2055
+ "version": "~18.2.0",
2056
+ "alwaysAddToPackageJson": false
2057
+ },
2058
+ "@angular-devkit/core": {
2059
+ "version": "~18.2.0",
2060
+ "alwaysAddToPackageJson": false
2061
+ },
2062
+ "@angular-devkit/schematics": {
2063
+ "version": "~18.2.0",
2064
+ "alwaysAddToPackageJson": false
2065
+ },
2066
+ "@angular/build": {
2067
+ "version": "~18.2.0",
2068
+ "alwaysAddToPackageJson": false
2069
+ },
2070
+ "@angular/pwa": {
2071
+ "version": "~18.2.0",
2072
+ "alwaysAddToPackageJson": false
2073
+ },
2074
+ "@angular/ssr": {
2075
+ "version": "~18.2.0",
2076
+ "alwaysAddToPackageJson": false
2077
+ },
2078
+ "@schematics/angular": {
2079
+ "version": "~18.2.0",
2080
+ "alwaysAddToPackageJson": false
2081
+ },
2082
+ "@angular-devkit/architect": {
2083
+ "version": "~0.1802.0",
2084
+ "alwaysAddToPackageJson": false
2085
+ },
2086
+ "@angular-devkit/build-webpack": {
2087
+ "version": "~0.1802.0",
2088
+ "alwaysAddToPackageJson": false
2089
+ },
2090
+ "@angular/core": {
2091
+ "version": "~18.2.0",
2092
+ "alwaysAddToPackageJson": true
2093
+ },
2094
+ "@angular/material": {
2095
+ "version": "~18.2.0",
2096
+ "alwaysAddToPackageJson": false
2097
+ },
2098
+ "@angular/cdk": {
2099
+ "version": "~18.2.0",
2100
+ "alwaysAddToPackageJson": false
2101
+ },
2102
+ "ng-packagr": {
2103
+ "version": "~18.2.0",
2104
+ "alwaysAddToPackageJson": false
2105
+ }
2106
+ }
2031
2107
  }
2032
2108
  }
2033
2109
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "19.6.0-canary.20240814-6d83ae2",
3
+ "version": "19.6.0-rc.0",
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": {
@@ -79,14 +79,14 @@
79
79
  "webpack-merge": "^5.8.0",
80
80
  "webpack": "^5.88.0",
81
81
  "@module-federation/enhanced": "~0.2.3",
82
- "@nx/devkit": "19.6.0-canary.20240814-6d83ae2",
83
- "@nx/js": "19.6.0-canary.20240814-6d83ae2",
84
- "@nx/eslint": "19.6.0-canary.20240814-6d83ae2",
85
- "@nx/webpack": "19.6.0-canary.20240814-6d83ae2",
86
- "@nx/web": "19.6.0-canary.20240814-6d83ae2",
87
- "@nx/workspace": "19.6.0-canary.20240814-6d83ae2",
82
+ "@nx/devkit": "19.6.0-rc.0",
83
+ "@nx/js": "19.6.0-rc.0",
84
+ "@nx/eslint": "19.6.0-rc.0",
85
+ "@nx/webpack": "19.6.0-rc.0",
86
+ "@nx/web": "19.6.0-rc.0",
87
+ "@nx/workspace": "19.6.0-rc.0",
88
88
  "piscina": "^4.4.0",
89
- "@nrwl/angular": "19.6.0-canary.20240814-6d83ae2"
89
+ "@nrwl/angular": "19.6.0-rc.0"
90
90
  },
91
91
  "peerDependencies": {
92
92
  "@angular-devkit/build-angular": ">= 16.0.0 < 19.0.0",
@@ -0,0 +1,4 @@
1
+ import type { Schema } from '../schema';
2
+ import { type ExecutorContext } from '@nx/devkit';
3
+ import type { StaticRemotesConfig } from '@nx/webpack/src/utils/module-federation/parse-static-remotes-config';
4
+ export declare function buildStaticRemotes(staticRemotesConfig: StaticRemotesConfig, nxBin: any, context: ExecutorContext, options: Schema): Promise<Record<string, string>>;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildStaticRemotes = buildStaticRemotes;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const cache_directory_1 = require("nx/src/utils/cache-directory");
6
+ const node_child_process_1 = require("node:child_process");
7
+ const node_path_1 = require("node:path");
8
+ const node_fs_1 = require("node:fs");
9
+ async function buildStaticRemotes(staticRemotesConfig, nxBin, context, options) {
10
+ if (!staticRemotesConfig.remotes.length) {
11
+ return;
12
+ }
13
+ const mappedLocationOfRemotes = {};
14
+ for (const app of staticRemotesConfig.remotes) {
15
+ mappedLocationOfRemotes[app] = `http${options.ssl ? 's' : ''}://${options.host}:${options.staticRemotesPort}/${staticRemotesConfig.config[app].urlSegment}`;
16
+ }
17
+ await new Promise((resolve, reject) => {
18
+ devkit_1.logger.info(`NX Building ${staticRemotesConfig.remotes.length} static remotes...`);
19
+ const staticProcess = (0, node_child_process_1.fork)(nxBin, [
20
+ 'run-many',
21
+ `--target=server`,
22
+ `--projects=${staticRemotesConfig.remotes.join(',')}`,
23
+ ...(context.configurationName
24
+ ? [`--configuration=${context.configurationName}`]
25
+ : []),
26
+ ...(options.parallel ? [`--parallel=${options.parallel}`] : []),
27
+ ], {
28
+ cwd: context.root,
29
+ stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
30
+ });
31
+ // File to debug build failures e.g. 2024-01-01T00_00_0_0Z-build.log'
32
+ const remoteBuildLogFile = (0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, `${new Date().toISOString().replace(/[:\.]/g, '_')}-build.log`);
33
+ const stdoutStream = (0, node_fs_1.createWriteStream)(remoteBuildLogFile);
34
+ staticProcess.stdout.on('data', (data) => {
35
+ const ANSII_CODE_REGEX = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
36
+ const stdoutString = data.toString().replace(ANSII_CODE_REGEX, '');
37
+ stdoutStream.write(stdoutString);
38
+ // in addition to writing into the stdout stream, also show error directly in console
39
+ // so the error is easily discoverable. 'ERROR in' is the key word to search in webpack output.
40
+ if (stdoutString.includes('ERROR in')) {
41
+ devkit_1.logger.log(stdoutString);
42
+ }
43
+ if (stdoutString.includes('Successfully ran target server')) {
44
+ staticProcess.stdout.removeAllListeners('data');
45
+ devkit_1.logger.info(`NX Built ${staticRemotesConfig.remotes.length} static remotes`);
46
+ resolve();
47
+ }
48
+ });
49
+ staticProcess.stderr.on('data', (data) => devkit_1.logger.info(data.toString()));
50
+ staticProcess.once('exit', (code) => {
51
+ stdoutStream.end();
52
+ staticProcess.stdout.removeAllListeners('data');
53
+ staticProcess.stderr.removeAllListeners('data');
54
+ if (code !== 0) {
55
+ reject(`Remote failed to start. A complete log can be found in: ${remoteBuildLogFile}`);
56
+ }
57
+ else {
58
+ resolve();
59
+ }
60
+ });
61
+ process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
62
+ process.on('exit', () => staticProcess.kill('SIGTERM'));
63
+ });
64
+ return mappedLocationOfRemotes;
65
+ }
@@ -0,0 +1,2 @@
1
+ import type { Schema } from '../schema';
2
+ export declare function normalizeOptions(options: Schema): Schema;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeOptions = normalizeOptions;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const path_1 = require("path");
6
+ function normalizeOptions(options) {
7
+ const devServeRemotes = !options.devRemotes
8
+ ? []
9
+ : Array.isArray(options.devRemotes)
10
+ ? options.devRemotes
11
+ : [options.devRemotes];
12
+ return {
13
+ ...options,
14
+ devRemotes: devServeRemotes,
15
+ ssl: options.ssl ?? false,
16
+ sslCert: options.sslCert ? (0, path_1.join)(devkit_1.workspaceRoot, options.sslCert) : undefined,
17
+ sslKey: options.sslKey ? (0, path_1.join)(devkit_1.workspaceRoot, options.sslKey) : undefined,
18
+ };
19
+ }
@@ -0,0 +1,5 @@
1
+ import { type Schema } from '../schema';
2
+ import { type ExecutorContext, type ProjectConfiguration } from '@nx/devkit';
3
+ export declare function startRemotes(remotes: string[], workspaceProjects: Record<string, ProjectConfiguration>, options: Schema, context: ExecutorContext): Promise<AsyncIterable<{
4
+ success: boolean;
5
+ }>[]>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startRemotes = startRemotes;
4
+ const devkit_1 = require("@nx/devkit");
5
+ async function startRemotes(remotes, workspaceProjects, options, context) {
6
+ const target = 'serve-ssr';
7
+ const remoteIters = [];
8
+ for (const app of remotes) {
9
+ if (!workspaceProjects[app].targets?.[target]) {
10
+ throw new Error(`Could not find "${target}" target in "${app}" project.`);
11
+ }
12
+ else if (!workspaceProjects[app].targets?.[target].executor) {
13
+ throw new Error(`Could not find executor for "${target}" target in "${app}" project.`);
14
+ }
15
+ const [_, executor] = workspaceProjects[app].targets[target].executor.split(':');
16
+ const isUsingModuleFederationSsrDevServerExecutor = executor.includes('module-federation-dev-ssr');
17
+ const configurationOverride = options.devRemotes.find((r) => typeof r !== 'string' && r.remoteName === app)?.configuration;
18
+ remoteIters.push(await (0, devkit_1.runExecutor)({
19
+ project: app,
20
+ target,
21
+ configuration: configurationOverride ?? context.configurationName,
22
+ }, {
23
+ ...{ verbose: options.verbose ?? false },
24
+ ...(isUsingModuleFederationSsrDevServerExecutor
25
+ ? { isInitialHost: false }
26
+ : {}),
27
+ }, context));
28
+ }
29
+ return remoteIters;
30
+ }
@@ -0,0 +1,9 @@
1
+ import { type ExecutorContext } from '@nx/devkit';
2
+ import { type Schema } from '../schema';
3
+ import type { StaticRemotesConfig } from '@nx/webpack/src/utils/module-federation/parse-static-remotes-config';
4
+ export declare function startStaticRemotes(ssrStaticRemotesConfig: StaticRemotesConfig, context: ExecutorContext, options: Schema): AsyncGenerator<{
5
+ success: boolean;
6
+ baseUrl: string;
7
+ }, {
8
+ success: boolean;
9
+ }, unknown>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startStaticRemotes = startStaticRemotes;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const file_server_impl_1 = tslib_1.__importDefault(require("@nx/web/src/executors/file-server/file-server.impl"));
7
+ const path_1 = require("path");
8
+ const fs_1 = require("fs");
9
+ function startStaticRemotes(ssrStaticRemotesConfig, context, options) {
10
+ if (ssrStaticRemotesConfig.remotes.length === 0) {
11
+ return;
12
+ }
13
+ // The directories are usually generated with /browser and /server suffixes so we need to copy them to a common directory
14
+ const commonOutputDirectory = (0, path_1.join)(devkit_1.workspaceRoot, 'tmp/static-remotes');
15
+ for (const app of ssrStaticRemotesConfig.remotes) {
16
+ const remoteConfig = ssrStaticRemotesConfig.config[app];
17
+ (0, fs_1.cpSync)(remoteConfig.outputPath, (0, path_1.join)(commonOutputDirectory, remoteConfig.urlSegment), {
18
+ force: true,
19
+ recursive: true,
20
+ });
21
+ }
22
+ const staticRemotesIter = (0, file_server_impl_1.default)({
23
+ cors: true,
24
+ watch: false,
25
+ staticFilePath: commonOutputDirectory,
26
+ parallel: false,
27
+ spa: false,
28
+ withDeps: false,
29
+ host: options.host,
30
+ port: options.staticRemotesPort,
31
+ ssl: options.ssl,
32
+ sslCert: options.sslCert,
33
+ sslKey: options.sslKey,
34
+ cacheSeconds: -1,
35
+ }, context);
36
+ return staticRemotesIter;
37
+ }
@@ -0,0 +1,4 @@
1
+ import { type ExecutorContext } from '@nx/devkit';
2
+ import type { Schema } from './schema';
3
+ export declare function moduleFederationSsrDevServerExecutor(schema: Schema, context: ExecutorContext): AsyncGenerator<any, any, undefined>;
4
+ export default moduleFederationSsrDevServerExecutor;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.moduleFederationSsrDevServerExecutor = moduleFederationSsrDevServerExecutor;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const fs_1 = require("fs");
6
+ const project_graph_1 = require("nx/src/project-graph/project-graph");
7
+ const path_1 = require("path");
8
+ const module_federation_1 = require("../../builders/utilities/module-federation");
9
+ const module_federation_2 = require("@nx/webpack/src/utils/module-federation");
10
+ const parse_static_remotes_config_1 = require("@nx/webpack/src/utils/module-federation/parse-static-remotes-config");
11
+ const build_static_remotes_1 = require("./lib/build-static-remotes");
12
+ const start_dev_remotes_1 = require("./lib/start-dev-remotes");
13
+ const start_static_remotes_1 = require("./lib/start-static-remotes");
14
+ const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
15
+ const rxjs_for_await_1 = require("@nx/devkit/src/utils/rxjs-for-await");
16
+ const ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
17
+ const normalize_options_1 = require("./lib/normalize-options");
18
+ const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
19
+ const start_ssr_remote_proxies_1 = require("@nx/webpack/src/utils/module-federation/start-ssr-remote-proxies");
20
+ const dev_server_impl_1 = require("../../builders/dev-server/dev-server.impl");
21
+ async function* moduleFederationSsrDevServerExecutor(schema, context) {
22
+ const nxBin = require.resolve('nx/bin/nx');
23
+ const options = (0, normalize_options_1.normalizeOptions)(schema);
24
+ const currIter = (0, rxjs_for_await_1.eachValueFrom)((0, dev_server_impl_1.executeDevServerBuilder)(options, await (0, ngcli_adapter_1.createBuilderContext)({
25
+ builderName: '@nx/angular:webpack-server',
26
+ description: 'Build a ssr application',
27
+ optionSchema: require('../../builders/webpack-server/schema.json'),
28
+ }, context)));
29
+ if (options.isInitialHost === false) {
30
+ return yield* currIter;
31
+ }
32
+ const { projects: workspaceProjects } = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(context.projectGraph);
33
+ const project = workspaceProjects[context.projectName];
34
+ let pathToManifestFile;
35
+ if (options.pathToManifestFile) {
36
+ const userPathToManifestFile = (0, path_1.join)(context.root, options.pathToManifestFile);
37
+ if (!(0, fs_1.existsSync)(userPathToManifestFile)) {
38
+ throw new Error(`The provided Module Federation manifest file path does not exist. Please check the file exists at "${userPathToManifestFile}".`);
39
+ }
40
+ else if ((0, path_1.extname)(options.pathToManifestFile) !== '.json') {
41
+ throw new Error(`The Module Federation manifest file must be a JSON. Please ensure the file at ${userPathToManifestFile} is a JSON.`);
42
+ }
43
+ pathToManifestFile = userPathToManifestFile;
44
+ }
45
+ else {
46
+ pathToManifestFile = (0, module_federation_1.getDynamicMfManifestFile)(project, context.root);
47
+ }
48
+ (0, module_federation_1.validateDevRemotes)({ devRemotes: options.devRemotes }, workspaceProjects);
49
+ const moduleFederationConfig = (0, module_federation_2.getModuleFederationConfig)(project.targets.build.options.tsConfig, context.root, project.root, 'angular');
50
+ const remoteNames = options.devRemotes.map((r) => typeof r === 'string' ? r : r.remoteName);
51
+ const remotes = (0, module_federation_2.getRemotes)(remoteNames, options.skipRemotes, moduleFederationConfig, {
52
+ projectName: project.name,
53
+ projectGraph: context.projectGraph,
54
+ root: context.root,
55
+ }, pathToManifestFile);
56
+ options.staticRemotesPort ??= remotes.staticRemotePort;
57
+ const staticRemotesConfig = (0, parse_static_remotes_config_1.parseStaticSsrRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
58
+ const mappedLocationsOfStaticRemotes = await (0, build_static_remotes_1.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options);
59
+ // Set NX_MF_DEV_REMOTES for the Nx Runtime Library Control Plugin
60
+ process.env.NX_MF_DEV_REMOTES = JSON.stringify(options.devRemotes);
61
+ const devRemotes = await (0, start_dev_remotes_1.startRemotes)(remotes.devRemotes, workspaceProjects, options, context);
62
+ const staticRemotes = (0, start_static_remotes_1.startStaticRemotes)(staticRemotesConfig, context, options);
63
+ (0, start_ssr_remote_proxies_1.startSsrRemoteProxies)(staticRemotesConfig, mappedLocationsOfStaticRemotes, options.ssl
64
+ ? { pathToCert: options.sslCert, pathToKey: options.sslKey }
65
+ : undefined);
66
+ const removeBaseUrlEmission = (iter) => (0, async_iterable_1.mapAsyncIterable)(iter, (v) => ({
67
+ ...v,
68
+ baseUrl: undefined,
69
+ }));
70
+ return yield* (0, async_iterable_1.combineAsyncIterables)(removeBaseUrlEmission(currIter), ...devRemotes.map(removeBaseUrlEmission), ...(staticRemotes ? [removeBaseUrlEmission(staticRemotes)] : []), (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
71
+ if (!options.isInitialHost) {
72
+ done();
73
+ return;
74
+ }
75
+ if (remotes.remotePorts.length) {
76
+ devkit_1.logger.info(`Nx All remotes started, server ready at http://localhost:${options.port}`);
77
+ next({ success: true, baseUrl: `http://localhost:${options.port}` });
78
+ done();
79
+ return;
80
+ }
81
+ try {
82
+ const portsToWaitFor = staticRemotes
83
+ ? [options.staticRemotesPort, ...remotes.remotePorts]
84
+ : [...remotes.remotePorts];
85
+ await Promise.all(portsToWaitFor.map((port) => (0, wait_for_port_open_1.waitForPortOpen)(port, {
86
+ retries: 480,
87
+ retryDelay: 2500,
88
+ host: 'localhost',
89
+ })));
90
+ }
91
+ catch (error) {
92
+ throw new Error(`Failed to start remotes. Check above for any errors.`, {
93
+ cause: error,
94
+ });
95
+ }
96
+ finally {
97
+ done();
98
+ }
99
+ }));
100
+ }
101
+ exports.default = moduleFederationSsrDevServerExecutor;
@@ -1,3 +1,5 @@
1
+ import { type DevRemoteDefinition } from '../../builders/utilities/module-federation';
2
+
1
3
  export interface Schema {
2
4
  browserTarget: string;
3
5
  serverTarget: string;
@@ -10,8 +12,12 @@ export interface Schema {
10
12
  sslKey?: string;
11
13
  sslCert?: string;
12
14
  proxyConfig?: string;
13
- devRemotes?: string[];
15
+ devRemotes?: DevRemoteDefinition[];
14
16
  skipRemotes?: string[];
15
17
  verbose: boolean;
16
18
  pathToManifestFile?: string;
19
+ parallel?: number;
20
+ staticRemotesPort?: number;
21
+ parallel?: number;
22
+ isInitialHost?: boolean;
17
23
  }
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema",
3
3
  "title": "Module Federation SSR Dev Server Target",
4
- "description": "Serves host [Module Federation](https://module-federation.io/) applications ([webpack](https://webpack.js.org/)-based) that use SSR allowing to specify which remote applications should be served with the host.",
4
+ "outputCapture": "direct-nodejs",
5
+ "description": "The module-federation-ssr-dev-server executor is reserved exclusively for use with host SSR Module Federation applications. It allows the user to specify which remote applications should be served with the host.",
5
6
  "type": "object",
6
7
  "properties": {
7
8
  "browserTarget": {
@@ -63,7 +64,24 @@
63
64
  "devRemotes": {
64
65
  "type": "array",
65
66
  "items": {
66
- "type": "string"
67
+ "oneOf": [
68
+ {
69
+ "type": "string"
70
+ },
71
+ {
72
+ "type": "object",
73
+ "properties": {
74
+ "remoteName": {
75
+ "type": "string"
76
+ },
77
+ "configuration": {
78
+ "type": "string"
79
+ }
80
+ },
81
+ "required": ["remoteName"],
82
+ "additionalProperties": false
83
+ }
84
+ ]
67
85
  },
68
86
  "description": "List of remote applications to run in development mode (i.e. using serve target).",
69
87
  "x-priority": "important"
@@ -83,6 +101,20 @@
83
101
  "pathToManifestFile": {
84
102
  "type": "string",
85
103
  "description": "Path to a Module Federation manifest file (e.g. `my/path/to/module-federation.manifest.json`) containing the dynamic remote applications relative to the workspace root."
104
+ },
105
+ "isInitialHost": {
106
+ "type": "boolean",
107
+ "description": "Whether the host that is running this executor is the first in the project tree to do so.",
108
+ "default": true,
109
+ "x-priority": "internal"
110
+ },
111
+ "parallel": {
112
+ "type": "number",
113
+ "description": "Max number of parallel processes for building static remotes"
114
+ },
115
+ "staticRemotesPort": {
116
+ "type": "number",
117
+ "description": "The port at which to serve the file-server for the static remotes."
86
118
  }
87
119
  },
88
120
  "additionalProperties": false,
@@ -1,4 +1,4 @@
1
- import type { Plugin } from 'esbuild';
1
+ type Plugin = Parameters<typeof import('@angular-devkit/build-angular').buildApplication>[2]['codePlugins'][number];
2
2
  export type PluginSpec = {
3
3
  path: string;
4
4
  options: any;
@@ -6,3 +6,4 @@ export type PluginSpec = {
6
6
  export declare function loadPlugins(plugins: string[] | PluginSpec[] | undefined, tsConfig: string): Promise<Plugin[]>;
7
7
  export declare function loadMiddleware(middlewareFns: string[] | undefined, tsConfig: string): Promise<any[]>;
8
8
  export declare function loadIndexHtmlTransformer(indexHtmlTransformerPath: string, tsConfig: string): Promise<any>;
9
+ export {};
@@ -3,7 +3,8 @@
3
3
  "$id": "NxAngularComponentCypressSpecGenerator",
4
4
  "type": "object",
5
5
  "cli": "nx",
6
- "description": "Creates a Cypress spec for a UI component that has a story.",
6
+ "description": "Creates a Storybook Cypress spec for a UI component that has a story.",
7
+ "x-deprecated": "Use interactionTests instead. This option will be removed in v20.",
7
8
  "properties": {
8
9
  "projectName": {
9
10
  "type": "string",
@@ -1,3 +1,8 @@
1
1
  const { withModuleFederationForSSR } = require('@nx/angular/module-federation');
2
2
  const config = require('./module-federation.config');
3
- module.exports = withModuleFederationForSSR(config)
3
+ /**
4
+ * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
5
+ * The DTS Plugin can be enabled by setting dts: true
6
+ * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
7
+ */
8
+ module.exports = withModuleFederationForSSR(config, { dts: false });
@@ -1,4 +1,9 @@
1
1
  import { withModuleFederationForSSR } from '@nx/angular/module-federation';
2
2
  import config from './module-federation.config';
3
3
 
4
- export default withModuleFederationForSSR(config);
4
+ /**
5
+ * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
6
+ * The DTS Plugin can be enabled by setting dts: true
7
+ * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
8
+ */
9
+ export default withModuleFederationForSSR(config, { dts: false });
@@ -1,3 +1,9 @@
1
1
  const { withModuleFederationForSSR } = require('@nx/angular/module-federation');
2
2
  const config = require('./module-federation.config');
3
- module.exports = withModuleFederationForSSR(config)
3
+
4
+ /**
5
+ * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
6
+ * The DTS Plugin can be enabled by setting dts: true
7
+ * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
8
+ */
9
+ module.exports = withModuleFederationForSSR(config, { dts: false })
@@ -1,4 +1,9 @@
1
1
  import { withModuleFederationForSSR } from '@nx/angular/module-federation';
2
2
  import config from './module-federation.config';
3
3
 
4
- export default withModuleFederationForSSR(config);
4
+ /**
5
+ * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
6
+ * The DTS Plugin can be enabled by setting dts: true
7
+ * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
8
+ */
9
+ export default withModuleFederationForSSR(config, { dts: false });
@@ -1,4 +1,9 @@
1
1
  import { withModuleFederation } from '@nx/angular/module-federation';
2
2
  import config from './module-federation.config';
3
3
 
4
- export default withModuleFederation(config);
4
+ /**
5
+ * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
6
+ * The DTS Plugin can be enabled by setting dts: true
7
+ * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
8
+ */
9
+ export default withModuleFederation(config, { dts: false });
@@ -1,6 +1,11 @@
1
1
  import { withModuleFederation } from '@nx/angular/module-federation';
2
2
  import config from './module-federation.config';
3
3
 
4
+ /**
5
+ * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
6
+ * The DTS Plugin can be enabled by setting dts: true
7
+ * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
8
+ */
4
9
  export default withModuleFederation({
5
10
  ...config,
6
11
  /*
@@ -13,4 +18,4 @@ export default withModuleFederation({
13
18
  * ['app2', 'https://app2.example.com'],
14
19
  * ]
15
20
  */
16
- });
21
+ }, { dts: false });
@@ -1,3 +1,9 @@
1
1
  const { withModuleFederation } = require('@nx/angular/module-federation');
2
2
  const config = require('./module-federation.config');
3
- module.exports = withModuleFederation(config);
3
+
4
+ /**
5
+ * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
6
+ * The DTS Plugin can be enabled by setting dts: true
7
+ * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
8
+ */
9
+ module.exports = withModuleFederation(config, { dts: false });
@@ -1,5 +1,11 @@
1
1
  const { withModuleFederation } = require('@nx/angular/module-federation');
2
2
  const config = require('./module-federation.config');
3
+
4
+ /**
5
+ * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
6
+ * The DTS Plugin can be enabled by setting dts: true
7
+ * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
8
+ */
3
9
  module.exports = withModuleFederation({
4
10
  ...config,
5
11
  /*
@@ -12,4 +18,4 @@ module.exports = withModuleFederation({
12
18
  * ['app2', 'https://app2.example.com'],
13
19
  * ]
14
20
  */
15
- });
21
+ }, { dts: false });
@@ -27,11 +27,13 @@
27
27
  },
28
28
  "generateCypressSpecs": {
29
29
  "type": "boolean",
30
- "description": "Specifies whether to automatically generate `*.spec.ts` files in the Cypress e2e app generated by the `cypress-configure` generator."
30
+ "description": "Specifies whether to automatically generate `*.spec.ts` files in the Cypress e2e app generated by the `cypress-configure` generator.",
31
+ "x-deprecated": "Use interactionTests instead. This option will be removed in v20."
31
32
  },
32
33
  "cypressProject": {
33
34
  "type": "string",
34
- "description": "The Cypress project to generate the stories under. This is inferred from `name` by default."
35
+ "description": "The Cypress project to generate the stories under. This is inferred from `name` by default.",
36
+ "x-deprecated": "Use interactionTests instead. This option will be removed in v20."
35
37
  },
36
38
  "skipFormat": {
37
39
  "description": "Skip formatting files.",
@@ -0,0 +1,2 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export default function (tree: Tree): Promise<void>;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const minimatch_1 = require("minimatch");
6
+ const tsquery_1 = require("@phenomnomnominal/tsquery");
7
+ async function default_1(tree) {
8
+ (0, devkit_1.visitNotIgnoredFiles)(tree, '', (path) => {
9
+ const webpackConfigGlob = '**/webpack*.config*.{js,ts,mjs,cjs}';
10
+ const result = (0, minimatch_1.minimatch)(path, webpackConfigGlob);
11
+ if (!result) {
12
+ return;
13
+ }
14
+ let webpackConfigContents = tree.read(path, 'utf-8');
15
+ if (!/withModuleFederationSSR|withModuleFederation/.test(webpackConfigContents)) {
16
+ return;
17
+ }
18
+ const WITH_MODULE_FEDERATION_SELECTOR = 'CallExpression:has(Identifier[name=withModuleFederation]),CallExpression:has(Identifier[name=withModuleFederationForSSR])';
19
+ const EXISTING_MF_OVERRIDES_SELECTOR = 'ObjectLiteralExpression';
20
+ const ast = tsquery_1.tsquery.ast(webpackConfigContents);
21
+ const withModuleFederationNodes = (0, tsquery_1.tsquery)(ast, WITH_MODULE_FEDERATION_SELECTOR, { visitAllChildren: true });
22
+ if (!withModuleFederationNodes.length) {
23
+ return;
24
+ }
25
+ const withModuleFederationNode = withModuleFederationNodes[0];
26
+ const existingOverridesNodes = (0, tsquery_1.tsquery)(withModuleFederationNode, EXISTING_MF_OVERRIDES_SELECTOR, { visitAllChildren: true });
27
+ if (!existingOverridesNodes.length) {
28
+ // doesn't exist, add it
29
+ webpackConfigContents = `${webpackConfigContents.slice(0, withModuleFederationNode.getEnd() - 1)},${JSON.stringify({ dts: false })}${webpackConfigContents.slice(withModuleFederationNode.getEnd() - 1)}`;
30
+ }
31
+ else {
32
+ let existingOverrideNode;
33
+ for (const node of existingOverridesNodes) {
34
+ if (!existingOverrideNode) {
35
+ existingOverrideNode = node;
36
+ }
37
+ if (existingOverrideNode.getText().includes(node.getText())) {
38
+ continue;
39
+ }
40
+ existingOverrideNode = node;
41
+ }
42
+ const DTS_PROPERTY_SELECTOR = 'PropertyAssignment > Identifier[name=dts]';
43
+ const dtsPropertyNode = (0, tsquery_1.tsquery)(existingOverrideNode, DTS_PROPERTY_SELECTOR);
44
+ if (dtsPropertyNode.length) {
45
+ // dts already exists, do nothing
46
+ return;
47
+ }
48
+ const newOverrides = `{ dts: false, ${existingOverrideNode
49
+ .getText()
50
+ .slice(1)}`;
51
+ webpackConfigContents = `${webpackConfigContents.slice(0, existingOverrideNode.getStart())}${newOverrides}${webpackConfigContents.slice(existingOverrideNode.getEnd())}`;
52
+ }
53
+ tree.write(path, webpackConfigContents);
54
+ });
55
+ await (0, devkit_1.formatFiles)(tree);
56
+ }
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare const angularCliVersion = "~18.2.0";
3
+ export default function (tree: Tree): Promise<void>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.angularCliVersion = void 0;
4
+ exports.default = default_1;
5
+ const devkit_1 = require("@nx/devkit");
6
+ exports.angularCliVersion = '~18.2.0';
7
+ async function default_1(tree) {
8
+ let shouldFormat = false;
9
+ (0, devkit_1.updateJson)(tree, 'package.json', (json) => {
10
+ if (json.devDependencies?.['@angular/cli']) {
11
+ json.devDependencies['@angular/cli'] = exports.angularCliVersion;
12
+ shouldFormat = true;
13
+ }
14
+ else if (json.dependencies?.['@angular/cli']) {
15
+ json.dependencies['@angular/cli'] = exports.angularCliVersion;
16
+ shouldFormat = true;
17
+ }
18
+ return json;
19
+ });
20
+ if (shouldFormat) {
21
+ await (0, devkit_1.formatFiles)(tree);
22
+ }
23
+ }
@@ -1,7 +1,7 @@
1
1
  export declare const nxVersion: any;
2
- export declare const angularVersion = "~18.1.0";
3
- export declare const angularDevkitVersion = "~18.1.0";
4
- export declare const ngPackagrVersion = "~18.1.0";
2
+ export declare const angularVersion = "~18.2.0";
3
+ export declare const angularDevkitVersion = "~18.2.0";
4
+ export declare const ngPackagrVersion = "~18.2.0";
5
5
  export declare const ngrxVersion = "^18.0.1";
6
6
  export declare const rxjsVersion = "~7.8.0";
7
7
  export declare const zoneJsVersion = "~0.14.3";
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.jsoncEslintParserVersion = exports.jasmineMarblesVersion = exports.typesNodeVersion = exports.jestPresetAngularVersion = exports.tsNodeVersion = exports.autoprefixerVersion = exports.postcssUrlVersion = exports.postcssVersion = exports.tailwindVersion = exports.typescriptEslintVersion = exports.angularEslintVersion = exports.moduleFederationEnhancedVersion = exports.moduleFederationNodeVersion = exports.browserSyncVersion = exports.typesExpressVersion = exports.expressVersion = exports.typesCorsVersion = exports.corsVersion = exports.tsLibVersion = exports.angularJsVersion = exports.zoneJsVersion = exports.rxjsVersion = exports.ngrxVersion = exports.ngPackagrVersion = exports.angularDevkitVersion = exports.angularVersion = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
- exports.angularVersion = '~18.1.0';
6
- exports.angularDevkitVersion = '~18.1.0';
7
- exports.ngPackagrVersion = '~18.1.0';
5
+ exports.angularVersion = '~18.2.0';
6
+ exports.angularDevkitVersion = '~18.2.0';
7
+ exports.ngPackagrVersion = '~18.2.0';
8
8
  exports.ngrxVersion = '^18.0.1';
9
9
  exports.rxjsVersion = '~7.8.0';
10
10
  exports.zoneJsVersion = '~0.14.3';
@@ -1,4 +0,0 @@
1
- import type { Schema } from './schema';
2
- export declare function executeModuleFederationDevSSRBuilder(schema: Schema, context: import('@angular-devkit/architect').BuilderContext): import("rxjs").Observable<unknown>;
3
- declare const _default: any;
4
- export default _default;
@@ -1,103 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeModuleFederationDevSSRBuilder = executeModuleFederationDevSSRBuilder;
4
- const devkit_1 = require("@nx/devkit");
5
- const child_process_1 = require("child_process");
6
- const fs_1 = require("fs");
7
- const ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
8
- const executor_utils_1 = require("nx/src/command-line/run/executor-utils");
9
- const project_graph_1 = require("nx/src/project-graph/project-graph");
10
- const path_1 = require("path");
11
- const rxjs_1 = require("rxjs");
12
- const operators_1 = require("rxjs/operators");
13
- const angular_version_utils_1 = require("../../executors/utilities/angular-version-utils");
14
- const module_federation_1 = require("../utilities/module-federation");
15
- function executeModuleFederationDevSSRBuilder(schema, context) {
16
- const { ...options } = schema;
17
- const projectGraph = (0, devkit_1.readCachedProjectGraph)();
18
- const { projects: workspaceProjects } = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
19
- const project = workspaceProjects[context.target.project];
20
- let pathToManifestFile;
21
- if (options.pathToManifestFile) {
22
- const userPathToManifestFile = (0, path_1.join)(context.workspaceRoot, options.pathToManifestFile);
23
- if (!(0, fs_1.existsSync)(userPathToManifestFile)) {
24
- throw new Error(`The provided Module Federation manifest file path does not exist. Please check the file exists at "${userPathToManifestFile}".`);
25
- }
26
- else if ((0, path_1.extname)(options.pathToManifestFile) !== '.json') {
27
- throw new Error(`The Module Federation manifest file must be a JSON. Please ensure the file at ${userPathToManifestFile} is a JSON.`);
28
- }
29
- pathToManifestFile = userPathToManifestFile;
30
- }
31
- else {
32
- pathToManifestFile = (0, module_federation_1.getDynamicMfManifestFile)(project, context.workspaceRoot);
33
- }
34
- const devServeRemotes = !options.devRemotes
35
- ? []
36
- : Array.isArray(options.devRemotes)
37
- ? options.devRemotes
38
- : [options.devRemotes];
39
- // Set NX_MF_DEV_REMOTES for the Nx Runtime Library Control Plugin
40
- process.env.NX_MF_DEV_REMOTES = JSON.stringify(devServeRemotes);
41
- (0, module_federation_1.validateDevRemotes)({ devRemotes: devServeRemotes }, workspaceProjects);
42
- const remotesToSkip = new Set(options.skipRemotes ?? []);
43
- const staticRemotes = (0, module_federation_1.getStaticRemotes)(project, context, workspaceProjects, remotesToSkip);
44
- const dynamicRemotes = (0, module_federation_1.getDynamicRemotes)(project, context, workspaceProjects, remotesToSkip, pathToManifestFile);
45
- const remotes = [...staticRemotes, ...dynamicRemotes];
46
- const remoteProcessPromises = [];
47
- for (const remote of remotes) {
48
- const isDev = devServeRemotes.includes(remote);
49
- const target = isDev ? 'serve-ssr' : 'static-server';
50
- if (!workspaceProjects[remote].targets?.[target]) {
51
- throw new Error(`Could not find "${target}" target in "${remote}" project.`);
52
- }
53
- else if (!workspaceProjects[remote].targets?.[target].executor) {
54
- throw new Error(`Could not find executor for "${target}" target in "${remote}" project.`);
55
- }
56
- const runOptions = {};
57
- if (options.verbose) {
58
- const [collection, executor] = workspaceProjects[remote].targets[target].executor.split(':');
59
- const { schema } = (0, executor_utils_1.getExecutorInformation)(collection, executor, devkit_1.workspaceRoot, workspaceProjects);
60
- if (schema.additionalProperties || 'verbose' in schema.properties) {
61
- runOptions.verbose = options.verbose;
62
- }
63
- }
64
- const remotePromise = new Promise((res, rej) => {
65
- if (target === 'static-server') {
66
- const remoteProject = workspaceProjects[remote];
67
- const remoteServerOutput = (0, path_1.join)(devkit_1.workspaceRoot, remoteProject.targets.server.options.outputPath, 'main.js');
68
- const pm = (0, devkit_1.getPackageManagerCommand)();
69
- (0, child_process_1.execSync)(`${pm.exec} nx run ${remote}:server${context.target.configuration
70
- ? `:${context.target.configuration}`
71
- : ''}`, { stdio: 'inherit' });
72
- const child = (0, child_process_1.fork)(remoteServerOutput, {
73
- env: { PORT: remoteProject.targets['serve-ssr'].options.port },
74
- });
75
- child.on('message', (msg) => {
76
- if (msg === 'nx.server.ready') {
77
- res();
78
- }
79
- });
80
- }
81
- if (target === 'serve-ssr') {
82
- (0, ngcli_adapter_1.scheduleTarget)(context.workspaceRoot, {
83
- project: remote,
84
- target,
85
- configuration: context.target.configuration,
86
- runOptions,
87
- projects: workspaceProjects,
88
- }, options.verbose).then((obs) => obs
89
- .pipe((0, operators_1.tap)((result) => {
90
- result.success && res();
91
- }))
92
- .toPromise());
93
- }
94
- });
95
- remoteProcessPromises.push(remotePromise);
96
- }
97
- const { major: angularMajorVersion } = (0, angular_version_utils_1.getInstalledAngularVersionInfo)();
98
- const { executeSSRDevServerBuilder } = angularMajorVersion >= 17
99
- ? require('@angular-devkit/build-angular')
100
- : require('@nguniversal/builders');
101
- return (0, rxjs_1.from)(Promise.all(remoteProcessPromises)).pipe((0, operators_1.switchMap)(() => executeSSRDevServerBuilder(options, context)));
102
- }
103
- exports.default = require('@angular-devkit/architect').createBuilder(executeModuleFederationDevSSRBuilder);