@nx/angular 20.2.0-canary.20241203-6b87005 → 20.2.0-canary.20241205-15060e3

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.
Files changed (31) hide show
  1. package/generators.json +4 -2
  2. package/migrations.json +24 -15
  3. package/package.json +12 -12
  4. package/src/executors/module-federation-dev-server/lib/index.d.ts +0 -2
  5. package/src/executors/module-federation-dev-server/lib/index.js +0 -2
  6. package/src/executors/module-federation-dev-server/lib/normalize-options.js +1 -0
  7. package/src/executors/module-federation-dev-server/lib/start-dev-remotes.d.ts +1 -1
  8. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +2 -26
  9. package/src/executors/module-federation-dev-server/schema.d.ts +1 -0
  10. package/src/executors/module-federation-ssr-dev-server/lib/normalize-options.d.ts +2 -2
  11. package/src/executors/module-federation-ssr-dev-server/lib/normalize-options.js +1 -0
  12. package/src/executors/module-federation-ssr-dev-server/lib/start-dev-remotes.d.ts +1 -1
  13. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +10 -32
  14. package/src/executors/module-federation-ssr-dev-server/schema.d.ts +6 -0
  15. package/src/generators/federate-module/schema.json +18 -11
  16. package/src/generators/host/schema.json +13 -8
  17. package/src/generators/remote/schema.json +13 -8
  18. package/src/generators/setup-mf/schema.json +5 -3
  19. package/src/generators/utils/add-jest.js +4 -8
  20. package/src/migrations/update-20-2-0/disable-angular-eslint-prefer-standalone.d.ts +2 -0
  21. package/src/migrations/update-20-2-0/disable-angular-eslint-prefer-standalone.js +55 -0
  22. package/src/utils/versions.d.ts +1 -1
  23. package/src/utils/versions.js +1 -1
  24. package/src/executors/module-federation-dev-server/lib/build-static-remotes.d.ts +0 -4
  25. package/src/executors/module-federation-dev-server/lib/build-static-remotes.js +0 -65
  26. package/src/executors/module-federation-dev-server/lib/start-static-remotes-file-server.d.ts +0 -9
  27. package/src/executors/module-federation-dev-server/lib/start-static-remotes-file-server.js +0 -51
  28. package/src/executors/module-federation-ssr-dev-server/lib/build-static-remotes.d.ts +0 -4
  29. package/src/executors/module-federation-ssr-dev-server/lib/build-static-remotes.js +0 -65
  30. package/src/executors/module-federation-ssr-dev-server/lib/start-static-remotes.d.ts +0 -4
  31. package/src/executors/module-federation-ssr-dev-server/lib/start-static-remotes.js +0 -41
package/generators.json CHANGED
@@ -73,7 +73,8 @@
73
73
  "factory": "./src/generators/remote/remote",
74
74
  "schema": "./src/generators/remote/schema.json",
75
75
  "x-type": "application",
76
- "description": "Generate a Remote Angular Module Federation Application."
76
+ "description": "Generate a Remote Angular Module Federation Application.",
77
+ "aliases": ["producer"]
77
78
  },
78
79
  "move": {
79
80
  "factory": "./src/generators/move/move#angularMoveGenerator",
@@ -91,7 +92,8 @@
91
92
  "factory": "./src/generators/host/host",
92
93
  "schema": "./src/generators/host/schema.json",
93
94
  "x-type": "application",
94
- "description": "Generate a Host Angular Module Federation Application."
95
+ "description": "Generate a Host Angular Module Federation Application.",
96
+ "aliases": ["consumer"]
95
97
  },
96
98
  "ng-add": {
97
99
  "factory": "./src/generators/ng-add/ng-add",
package/migrations.json CHANGED
@@ -292,7 +292,7 @@
292
292
  "cli": "nx",
293
293
  "version": "20.2.0-beta.5",
294
294
  "requires": {
295
- "@angular/core": ">=19.0.0-rc.1"
295
+ "@angular/core": ">=19.0.0"
296
296
  },
297
297
  "description": "Add the '@angular/localize/init' polyfill to the 'polyfills' option of targets using esbuild-based executors.",
298
298
  "factory": "./src/migrations/update-20-2-0/add-localize-polyfill-to-targets"
@@ -301,10 +301,19 @@
301
301
  "cli": "nx",
302
302
  "version": "20.2.0-beta.5",
303
303
  "requires": {
304
- "@angular/core": ">=19.0.0-rc.1"
304
+ "@angular/core": ">=19.0.0"
305
305
  },
306
306
  "description": "Update '@angular/ssr' import paths to use the new '/node' entry point when 'CommonEngine' is detected.",
307
307
  "factory": "./src/migrations/update-20-2-0/update-angular-ssr-imports-to-use-node-entry-point"
308
+ },
309
+ "disable-angular-eslint-prefer-standalone": {
310
+ "cli": "nx",
311
+ "version": "20.2.0-beta.6",
312
+ "requires": {
313
+ "@angular/core": ">=19.0.0"
314
+ },
315
+ "description": "Disable the Angular ESLint prefer-standalone rule if not set.",
316
+ "factory": "./src/migrations/update-20-2-0/disable-angular-eslint-prefer-standalone"
308
317
  }
309
318
  },
310
319
  "packageJsonUpdates": {
@@ -1284,19 +1293,6 @@
1284
1293
  }
1285
1294
  }
1286
1295
  },
1287
- "20.2.0-analog": {
1288
- "version": "20.2.0-beta.5",
1289
- "packages": {
1290
- "@analogjs/vitest-angular": {
1291
- "version": "~1.10.0-beta.6",
1292
- "alwaysAddToPackageJson": false
1293
- },
1294
- "@analogjs/vite-plugin-angular": {
1295
- "version": "~1.10.0-beta.6",
1296
- "alwaysAddToPackageJson": false
1297
- }
1298
- }
1299
- },
1300
1296
  "20.2.0-jest": {
1301
1297
  "version": "20.2.0-beta.5",
1302
1298
  "requires": {
@@ -1341,6 +1337,19 @@
1341
1337
  "alwaysAddToPackageJson": false
1342
1338
  }
1343
1339
  }
1340
+ },
1341
+ "20.2.0-analog": {
1342
+ "version": "20.2.0-beta.7",
1343
+ "packages": {
1344
+ "@analogjs/vitest-angular": {
1345
+ "version": "~1.10.0",
1346
+ "alwaysAddToPackageJson": false
1347
+ },
1348
+ "@analogjs/vite-plugin-angular": {
1349
+ "version": "~1.10.0",
1350
+ "alwaysAddToPackageJson": false
1351
+ }
1352
+ }
1344
1353
  }
1345
1354
  }
1346
1355
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "20.2.0-canary.20241203-6b87005",
3
+ "version": "20.2.0-canary.20241205-15060e3",
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": {
@@ -71,20 +71,20 @@
71
71
  "semver": "^7.5.3",
72
72
  "tslib": "^2.3.0",
73
73
  "webpack-merge": "^5.8.0",
74
- "@nx/devkit": "20.2.0-canary.20241203-6b87005",
75
- "@nx/js": "20.2.0-canary.20241203-6b87005",
76
- "@nx/eslint": "20.2.0-canary.20241203-6b87005",
77
- "@nx/webpack": "20.2.0-canary.20241203-6b87005",
78
- "@nx/module-federation": "20.2.0-canary.20241203-6b87005",
79
- "@nx/web": "20.2.0-canary.20241203-6b87005",
80
- "@nx/workspace": "20.2.0-canary.20241203-6b87005",
74
+ "@nx/devkit": "20.2.0-canary.20241205-15060e3",
75
+ "@nx/js": "20.2.0-canary.20241205-15060e3",
76
+ "@nx/eslint": "20.2.0-canary.20241205-15060e3",
77
+ "@nx/webpack": "20.2.0-canary.20241205-15060e3",
78
+ "@nx/module-federation": "20.2.0-canary.20241205-15060e3",
79
+ "@nx/web": "20.2.0-canary.20241205-15060e3",
80
+ "@nx/workspace": "20.2.0-canary.20241205-15060e3",
81
81
  "piscina": "^4.4.0"
82
82
  },
83
83
  "peerDependencies": {
84
- "@angular-devkit/build-angular": ">= 16.0.0 < 19.0.0",
85
- "@angular-devkit/core": ">= 16.0.0 < 19.0.0",
86
- "@angular-devkit/schematics": ">= 16.0.0 < 19.0.0",
87
- "@schematics/angular": ">= 16.0.0 < 19.0.0",
84
+ "@angular-devkit/build-angular": ">= 17.0.0 < 20.0.0",
85
+ "@angular-devkit/core": ">= 17.0.0 < 20.0.0",
86
+ "@angular-devkit/schematics": ">= 17.0.0 < 20.0.0",
87
+ "@schematics/angular": ">= 17.0.0 < 20.0.0",
88
88
  "rxjs": "^6.5.3 || ^7.5.0"
89
89
  },
90
90
  "publishConfig": {
@@ -1,4 +1,2 @@
1
- export * from './build-static-remotes';
2
1
  export * from './normalize-options';
3
2
  export * from './start-dev-remotes';
4
- export * from './start-static-remotes-file-server';
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./build-static-remotes"), exports);
5
4
  tslib_1.__exportStar(require("./normalize-options"), exports);
6
5
  tslib_1.__exportStar(require("./start-dev-remotes"), exports);
7
- tslib_1.__exportStar(require("./start-static-remotes-file-server"), exports);
@@ -21,6 +21,7 @@ function normalizeOptions(schema) {
21
21
  liveReload: schema.liveReload ?? true,
22
22
  open: schema.open ?? false,
23
23
  ssl: schema.ssl ?? false,
24
+ verbose: schema.verbose ?? false,
24
25
  sslCert: schema.sslCert ? (0, path_1.join)(devkit_1.workspaceRoot, schema.sslCert) : undefined,
25
26
  sslKey: schema.sslKey ? (0, path_1.join)(devkit_1.workspaceRoot, schema.sslKey) : undefined,
26
27
  };
@@ -1,5 +1,5 @@
1
1
  import { type Schema } from '../schema';
2
2
  import { type ExecutorContext, type ProjectConfiguration } from '@nx/devkit';
3
- export declare function startRemotes(remotes: string[], workspaceProjects: Record<string, ProjectConfiguration>, options: Schema, context: ExecutorContext, target?: 'serve' | 'serve-static'): Promise<AsyncIterable<{
3
+ export declare function startRemotes(remotes: string[], workspaceProjects: Record<string, ProjectConfiguration>, options: Pick<Schema, 'devRemotes' | 'verbose'>, context: ExecutorContext, target?: 'serve' | 'serve-static'): Promise<AsyncIterable<{
4
4
  success: boolean;
5
5
  }>[]>;
@@ -6,7 +6,7 @@ const devkit_1 = require("@nx/devkit");
6
6
  const lib_1 = require("./lib");
7
7
  const rxjs_for_await_1 = require("@nx/devkit/src/utils/rxjs-for-await");
8
8
  const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
9
- const utils_1 = require("@nx/module-federation/src/utils");
9
+ const utils_1 = require("@nx/module-federation/src/executors/utils");
10
10
  const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
11
11
  const file_server_impl_1 = tslib_1.__importDefault(require("@nx/web/src/executors/file-server/file-server.impl"));
12
12
  const ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
@@ -15,8 +15,6 @@ const module_federation_1 = require("../../builders/utilities/module-federation"
15
15
  const path_1 = require("path");
16
16
  const fs_1 = require("fs");
17
17
  async function* moduleFederationDevServerExecutor(schema, context) {
18
- // Force Node to resolve to look for the nx binary that is inside node_modules
19
- const nxBin = require.resolve('nx/bin/nx');
20
18
  const options = (0, lib_1.normalizeOptions)(schema);
21
19
  const { projects: workspaceProjects } = (0, devkit_1.readProjectsConfigurationFromProjectGraph)(context.projectGraph);
22
20
  const project = workspaceProjects[context.projectName];
@@ -55,29 +53,7 @@ async function* moduleFederationDevServerExecutor(schema, context) {
55
53
  pathToManifestFile = userPathToManifestFile;
56
54
  }
57
55
  (0, module_federation_1.validateDevRemotes)(options, workspaceProjects);
58
- const moduleFederationConfig = (0, utils_1.getModuleFederationConfig)(project.targets.build.options.tsConfig, context.root, project.root, 'angular');
59
- const remoteNames = options.devRemotes.map((r) => typeof r === 'string' ? r : r.remoteName);
60
- const remotes = (0, utils_1.getRemotes)(remoteNames, options.skipRemotes, moduleFederationConfig, {
61
- projectName: project.name,
62
- projectGraph: context.projectGraph,
63
- root: context.root,
64
- }, pathToManifestFile);
65
- options.staticRemotesPort ??= remotes.staticRemotePort;
66
- // Set NX_MF_DEV_REMOTES for the Nx Runtime Library Control Plugin
67
- process.env.NX_MF_DEV_REMOTES = JSON.stringify([
68
- ...(remotes.devRemotes.map((r) => typeof r === 'string' ? r : r.remoteName) ?? []).map((r) => r.replace(/-/g, '_')),
69
- project.name.replace(/-/g, '_'),
70
- ]);
71
- const staticRemotesConfig = (0, utils_1.parseStaticRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
72
- const mappedLocationsOfStaticRemotes = await (0, lib_1.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options);
73
- const devRemoteIters = await (0, lib_1.startRemotes)(remotes.devRemotes, workspaceProjects, options, context, 'serve');
74
- const staticRemotesIter = (0, lib_1.startStaticRemotesFileServer)(staticRemotesConfig, context, options);
75
- (0, utils_1.startRemoteProxies)(staticRemotesConfig, mappedLocationsOfStaticRemotes, options.ssl
76
- ? {
77
- pathToCert: options.sslCert,
78
- pathToKey: options.sslKey,
79
- }
80
- : undefined);
56
+ const { remotes, staticRemotesIter, devRemoteIters } = await (0, utils_1.startRemoteIterators)(options, context, lib_1.startRemotes, pathToManifestFile, 'angular');
81
57
  const removeBaseUrlEmission = (iter) => (0, async_iterable_1.mapAsyncIterable)(iter, (v) => ({
82
58
  ...v,
83
59
  baseUrl: undefined,
@@ -43,4 +43,5 @@ export type NormalizedSchema = SchemaWithBuildTarget & {
43
43
  liveReload: boolean;
44
44
  open: boolean;
45
45
  ssl: boolean;
46
+ verbose: boolean;
46
47
  };
@@ -1,2 +1,2 @@
1
- import type { Schema } from '../schema';
2
- export declare function normalizeOptions(options: Schema): Schema;
1
+ import type { NormalizedSchema, Schema } from '../schema';
2
+ export declare function normalizeOptions(options: Schema): NormalizedSchema;
@@ -12,6 +12,7 @@ function normalizeOptions(options) {
12
12
  return {
13
13
  ...options,
14
14
  devRemotes: devServeRemotes,
15
+ verbose: options.verbose ?? false,
15
16
  ssl: options.ssl ?? false,
16
17
  sslCert: options.sslCert ? (0, path_1.join)(devkit_1.workspaceRoot, options.sslCert) : undefined,
17
18
  sslKey: options.sslKey ? (0, path_1.join)(devkit_1.workspaceRoot, options.sslKey) : undefined,
@@ -1,5 +1,5 @@
1
1
  import { type Schema } from '../schema';
2
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<{
3
+ export declare function startRemotes(remotes: string[], workspaceProjects: Record<string, ProjectConfiguration>, options: Pick<Schema, 'devRemotes' | 'verbose'>, context: ExecutorContext): Promise<AsyncIterable<{
4
4
  success: boolean;
5
5
  }>[]>;
@@ -3,21 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.moduleFederationSsrDevServerExecutor = moduleFederationSsrDevServerExecutor;
4
4
  const build_angular_1 = require("@angular-devkit/build-angular");
5
5
  const devkit_1 = require("@nx/devkit");
6
- const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
7
- const rxjs_for_await_1 = require("@nx/devkit/src/utils/rxjs-for-await");
8
- const utils_1 = require("@nx/module-federation/src/utils");
9
- const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
10
6
  const fs_1 = require("fs");
11
- const ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
12
7
  const project_graph_1 = require("nx/src/project-graph/project-graph");
13
8
  const path_1 = require("path");
14
9
  const module_federation_1 = require("../../builders/utilities/module-federation");
15
- const build_static_remotes_1 = require("./lib/build-static-remotes");
16
- const normalize_options_1 = require("./lib/normalize-options");
10
+ const utils_1 = require("@nx/module-federation/src/executors/utils");
17
11
  const start_dev_remotes_1 = require("./lib/start-dev-remotes");
18
- const start_static_remotes_1 = require("./lib/start-static-remotes");
12
+ const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
13
+ const rxjs_for_await_1 = require("@nx/devkit/src/utils/rxjs-for-await");
14
+ const ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
15
+ const normalize_options_1 = require("./lib/normalize-options");
16
+ const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
19
17
  async function* moduleFederationSsrDevServerExecutor(schema, context) {
20
- const nxBin = require.resolve('nx/bin/nx');
21
18
  const options = (0, normalize_options_1.normalizeOptions)(schema);
22
19
  const currIter = (0, rxjs_for_await_1.eachValueFrom)((0, build_angular_1.executeSSRDevServerBuilder)(options, await (0, ngcli_adapter_1.createBuilderContext)({
23
20
  builderName: '@nx/angular:webpack-server',
@@ -44,31 +41,12 @@ async function* moduleFederationSsrDevServerExecutor(schema, context) {
44
41
  pathToManifestFile = (0, module_federation_1.getDynamicMfManifestFile)(project, context.root);
45
42
  }
46
43
  (0, module_federation_1.validateDevRemotes)({ devRemotes: options.devRemotes }, workspaceProjects);
47
- const moduleFederationConfig = (0, utils_1.getModuleFederationConfig)(project.targets.build.options.tsConfig, context.root, project.root, 'angular');
48
- const remoteNames = options.devRemotes.map((r) => typeof r === 'string' ? r : r.remoteName);
49
- const remotes = (0, utils_1.getRemotes)(remoteNames, options.skipRemotes, moduleFederationConfig, {
50
- projectName: project.name,
51
- projectGraph: context.projectGraph,
52
- root: context.root,
53
- }, pathToManifestFile);
54
- options.staticRemotesPort ??= remotes.staticRemotePort;
55
- const staticRemotesConfig = (0, utils_1.parseStaticSsrRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
56
- const mappedLocationsOfStaticRemotes = await (0, build_static_remotes_1.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options);
57
- // Set NX_MF_DEV_REMOTES for the Nx Runtime Library Control Plugin
58
- process.env.NX_MF_DEV_REMOTES = JSON.stringify([
59
- ...(options.devRemotes.map((r) => typeof r === 'string' ? r : r.remoteName) ?? []).map((r) => r.replace(/-/g, '_')),
60
- project.name.replace(/-/g, '_'),
61
- ]);
62
- const devRemotes = await (0, start_dev_remotes_1.startRemotes)(remotes.devRemotes, workspaceProjects, options, context);
63
- const staticRemotes = (0, start_static_remotes_1.startStaticRemotes)(staticRemotesConfig, context, options);
64
- (0, utils_1.startSsrRemoteProxies)(staticRemotesConfig, mappedLocationsOfStaticRemotes, options.ssl
65
- ? { pathToCert: options.sslCert, pathToKey: options.sslKey }
66
- : undefined);
44
+ const { remotes, staticRemotesIter, devRemoteIters } = await (0, utils_1.startRemoteIterators)(options, context, start_dev_remotes_1.startRemotes, pathToManifestFile, 'angular', true);
67
45
  const removeBaseUrlEmission = (iter) => (0, async_iterable_1.mapAsyncIterable)(iter, (v) => ({
68
46
  ...v,
69
47
  baseUrl: undefined,
70
48
  }));
71
- const combined = (0, async_iterable_1.combineAsyncIterables)(removeBaseUrlEmission(staticRemotes), ...(devRemotes ? devRemotes.map(removeBaseUrlEmission) : []), (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
49
+ const combined = (0, async_iterable_1.combineAsyncIterables)(removeBaseUrlEmission(staticRemotesIter), ...(devRemoteIters ? devRemoteIters.map(removeBaseUrlEmission) : []), (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
72
50
  if (!options.isInitialHost) {
73
51
  done();
74
52
  return;
@@ -80,7 +58,7 @@ async function* moduleFederationSsrDevServerExecutor(schema, context) {
80
58
  return;
81
59
  }
82
60
  try {
83
- const portsToWaitFor = staticRemotes
61
+ const portsToWaitFor = staticRemotesIter
84
62
  ? [options.staticRemotesPort, ...remotes.remotePorts]
85
63
  : [...remotes.remotePorts];
86
64
  await Promise.all(portsToWaitFor.map((port) => (0, wait_for_port_open_1.waitForPortOpen)(port, {
@@ -99,7 +77,7 @@ async function* moduleFederationSsrDevServerExecutor(schema, context) {
99
77
  done();
100
78
  }
101
79
  }));
102
- let refs = 2 + (devRemotes?.length ?? 0);
80
+ let refs = 2 + (devRemoteIters?.length ?? 0);
103
81
  for await (const result of combined) {
104
82
  if (result.success === false)
105
83
  throw new Error('Remotes failed to start');
@@ -9,3 +9,9 @@ export interface Schema extends SSRDevServerBuilderOptions {
9
9
  staticRemotesPort?: number;
10
10
  isInitialHost?: boolean;
11
11
  }
12
+
13
+ export interface NormalizedSchema extends Schema {
14
+ devRemotes: DevRemoteDefinition[];
15
+ ssl: boolean;
16
+ verbose: boolean;
17
+ }
@@ -3,11 +3,15 @@
3
3
  "cli": "nx",
4
4
  "$id": "NxReactFederateModule",
5
5
  "title": "Federate Module",
6
- "description": "Create a federated module, which is exposed by a remote and can be subsequently loaded by a host.",
6
+ "description": "Create a federated module, which is exposed by a Producer (remote) and can be subsequently loaded by a Consumer (host).",
7
7
  "examples": [
8
8
  {
9
- "command": "nx g federate-module MyModule --path=./src/component/my-cmp.ts --remote=my-remote-app --remoteDirectory=apps/my-remote-app",
9
+ "command": "nx g federate-module MyModule --path=./src/component/my-cmp.ts --remote=myRemoteApp --remoteDirectory=apps/myRemoteApp",
10
10
  "description": "Create a federated module from my-remote-app, that exposes my-cmp from ./src/component/my-cmp.ts as MyModule."
11
+ },
12
+ {
13
+ "command": "nx g federate-module MyModule --path=./src/component/my-cmp.ts --producer=myProducer --producerDirectory=apps/myProducer",
14
+ "description": "Create a federated module from myProducer, that exposes my-cmp from ./src/component/my-cmp.ts as MyModule."
11
15
  }
12
16
  ],
13
17
  "type": "object",
@@ -30,15 +34,17 @@
30
34
  },
31
35
  "remote": {
32
36
  "type": "string",
33
- "description": "The name of the remote.",
34
- "x-prompt": "What is/should the remote be named?"
37
+ "description": "The name of the Producer (remote).",
38
+ "x-prompt": "What is/should the Producer (remote) be named?",
39
+ "alias": "producer"
35
40
  },
36
41
  "remoteDirectory": {
37
- "description": "The directory of the new remote application if one needs to be created.",
38
- "type": "string"
42
+ "description": "The directory of the new Producer (remote) application if one needs to be created.",
43
+ "type": "string",
44
+ "alias": "producerDirectory"
39
45
  },
40
46
  "style": {
41
- "description": "The file extension to be used for style files for the remote if one needs to be created.",
47
+ "description": "The file extension to be used for style files for the Producer (remote) if one needs to be created.",
42
48
  "type": "string",
43
49
  "default": "css",
44
50
  "enum": ["css", "scss", "sass", "less"]
@@ -52,24 +58,25 @@
52
58
  "unitTestRunner": {
53
59
  "type": "string",
54
60
  "enum": ["jest", "vitest", "none"],
55
- "description": "Test runner to use for unit tests of the remote if it needs to be created.",
61
+ "description": "Test runner to use for unit tests of the Producer (remote) if it needs to be created.",
56
62
  "x-prompt": "Which unit test runner would you like to use?",
57
63
  "default": "jest"
58
64
  },
59
65
  "e2eTestRunner": {
60
66
  "type": "string",
61
67
  "enum": ["cypress", "none"],
62
- "description": "Test runner to use for end to end (e2e) tests of the remote if it needs to be created.",
68
+ "description": "Test runner to use for end to end (e2e) tests of the Producer (remote) if it needs to be created.",
63
69
  "default": "cypress"
64
70
  },
65
71
  "standalone": {
66
- "description": "Whether to generate the remote application with standalone components if it needs to be created.",
72
+ "description": "Whether to generate the Producer (remote) application with standalone components if it needs to be created.",
67
73
  "type": "boolean",
68
74
  "default": true
69
75
  },
70
76
  "host": {
71
77
  "type": "string",
72
- "description": "The host / shell application for this remote."
78
+ "description": "The Consumer (host) application for this Producer (remote).",
79
+ "alias": "consumer"
73
80
  }
74
81
  },
75
82
  "required": ["name", "path", "remote"],
@@ -2,13 +2,17 @@
2
2
  "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxMFHost",
4
4
  "cli": "nx",
5
- "title": "Nx Module Federation Host Application",
6
- "description": "Create an Angular Host Module Federation Application.",
5
+ "title": "Nx Module Federation Consumer (Host) Application",
6
+ "description": "Create an Angular Consumer (Host) Module Federation Application.",
7
7
  "type": "object",
8
8
  "examples": [
9
9
  {
10
10
  "command": "nx g @nx/angular:host appName --remotes=remote1",
11
- "description": "Create an Angular application with configuration in place for Module Federation. If the `remotes` option is provided, attach the remote application to this application's configuration"
11
+ "description": "Create an Angular application with configuration in place for Module Federation. If the `remotes` option is provided, attach the Producer (remote) application to this application's configuration"
12
+ },
13
+ {
14
+ "command": "nx g @nx/angular:consumer appName --producers=remote1",
15
+ "description": "Create an Angular application with configuration in place for Module Federation. If the `producers` option is provided, attach the Producer (remote) application to this application's configuration"
12
16
  }
13
17
  ],
14
18
  "properties": {
@@ -23,14 +27,15 @@
23
27
  },
24
28
  "name": {
25
29
  "type": "string",
26
- "description": "The name to give to the host Angular application.",
30
+ "description": "The name to give to the Consumer (host) Angular application.",
27
31
  "pattern": "^[a-zA-Z][^:]*$",
28
32
  "x-priority": "important"
29
33
  },
30
34
  "remotes": {
31
35
  "type": "array",
32
- "description": "The names of the remote applications to add to the host.",
33
- "x-priority": "important"
36
+ "description": "The names of the Producers (remote) applications to add to the Consumer (host).",
37
+ "x-priority": "important",
38
+ "alias": "producers"
34
39
  },
35
40
  "dynamic": {
36
41
  "type": "boolean",
@@ -163,11 +168,11 @@
163
168
  },
164
169
  "standalone": {
165
170
  "type": "boolean",
166
- "description": "Whether to generate a host application that uses standalone components.",
171
+ "description": "Whether to generate a Consumer (host) application that uses standalone components.",
167
172
  "default": true
168
173
  },
169
174
  "ssr": {
170
- "description": "Whether to configure SSR for the host application",
175
+ "description": "Whether to configure SSR for the Consumer (host) application",
171
176
  "type": "boolean",
172
177
  "default": false,
173
178
  "x-priority": "important"
@@ -2,13 +2,17 @@
2
2
  "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxMFRemote",
4
4
  "cli": "nx",
5
- "title": "Nx Module Federation Remote App",
6
- "description": "Create an Angular Remote Module Federation Application.",
5
+ "title": "Nx Module Federation Producer (Remote) App",
6
+ "description": "Create an Angular Producer (Remote) Module Federation Application.",
7
7
  "type": "object",
8
8
  "examples": [
9
9
  {
10
10
  "command": "nx g @nx/angular:remote appName --host=host --port=4201",
11
- "description": "Create an Angular app with configuration in place for Module Federation. If host is provided, attach this remote app to host app's configuration."
11
+ "description": "Create an Angular app with configuration in place for Module Federation. If Consumer (host) is provided, attach this Producer (remote) app to Consumer (host) app's configuration."
12
+ },
13
+ {
14
+ "command": "nx g @nx/angular:producer appName --consumer=host --port=4201",
15
+ "description": "Create an Angular app with configuration in place for Module Federation. If Consumer (host) is provided, attach this Producer (remote) app to Consumer (host) app's configuration."
12
16
  }
13
17
  ],
14
18
  "properties": {
@@ -23,15 +27,16 @@
23
27
  },
24
28
  "name": {
25
29
  "type": "string",
26
- "description": "The name to give to the remote Angular app.",
30
+ "description": "The name to give to the Producer (remote) Angular app.",
27
31
  "pattern": "^[a-zA-Z_$][a-zA-Z_$0-9]*$",
28
32
  "x-priority": "important"
29
33
  },
30
34
  "host": {
31
35
  "type": "string",
32
- "description": "The name of the host app to attach this remote app to.",
36
+ "description": "The name of the Consumer (host) app to attach this Producer (remote) app to.",
33
37
  "x-dropdown": "projects",
34
- "x-priority": "important"
38
+ "x-priority": "important",
39
+ "alias": "consumer"
35
40
  },
36
41
  "port": {
37
42
  "type": "number",
@@ -156,12 +161,12 @@
156
161
  "x-priority": "internal"
157
162
  },
158
163
  "standalone": {
159
- "description": "Whether to generate a remote application with standalone components.",
164
+ "description": "Whether to generate a Producer (remote) application with standalone components.",
160
165
  "type": "boolean",
161
166
  "default": true
162
167
  },
163
168
  "ssr": {
164
- "description": "Whether to configure SSR for the remote application to be consumed by a host application using SSR.",
169
+ "description": "Whether to configure SSR for the Producer (remote) application to be consumed by a Consumer (host) application using SSR.",
165
170
  "type": "boolean",
166
171
  "default": false
167
172
  },
@@ -34,15 +34,17 @@
34
34
  },
35
35
  "remotes": {
36
36
  "type": "array",
37
- "description": "A list of remote application names that the host application should consume."
37
+ "description": "A list of remote application names that the Consumer (host) application should consume.",
38
+ "alias": "producers"
38
39
  },
39
40
  "host": {
40
41
  "type": "string",
41
- "description": "The name of the host application that the remote application will be consumed by."
42
+ "description": "The name of the host application that the remote application will be consumed by.",
43
+ "alias": "consumer"
42
44
  },
43
45
  "routing": {
44
46
  "type": "boolean",
45
- "description": "Generate a routing setup to allow a host application to route to the remote application.",
47
+ "description": "Generate a routing setup to allow a Consumer (host) application to route to the Producer (remote) application.",
46
48
  "x-priority": "important"
47
49
  },
48
50
  "skipFormat": {
@@ -22,13 +22,9 @@ async function addJest(tree, options) {
22
22
  const setupFile = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src', 'test-setup.ts');
23
23
  if (options.strict && tree.exists(setupFile)) {
24
24
  const contents = tree.read(setupFile, 'utf-8');
25
- tree.write(setupFile, `// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
26
- globalThis.ngJest = {
27
- testEnvironmentOptions: {
28
- errorOnUnknownElements: true,
29
- errorOnUnknownProperties: true,
30
- },
31
- };
32
- ${contents}`);
25
+ tree.write(setupFile, contents.replace('setupZoneTestEnv();', `setupZoneTestEnv({
26
+ errorOnUnknownElements: true,
27
+ errorOnUnknownProperties: true
28
+ });`));
33
29
  }
34
30
  }
@@ -0,0 +1,2 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export default function (tree: Tree): Promise<void>;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
6
+ const projects_1 = require("../utils/projects");
7
+ const preferStandaloneRule = '@angular-eslint/prefer-standalone';
8
+ async function default_1(tree) {
9
+ const projects = await (0, projects_1.getProjectsFilteredByDependencies)(tree, [
10
+ 'npm:@angular/core',
11
+ ]);
12
+ for (const { project: { root }, } of projects) {
13
+ if (!(0, eslint_file_1.isEslintConfigSupported)(tree, root)) {
14
+ // ESLint config is not supported, skip
15
+ continue;
16
+ }
17
+ if ((0, eslint_file_1.lintConfigHasOverride)(tree, root, (o) => !!o.rules?.[preferStandaloneRule], true)) {
18
+ // the @angular-eslint/prefer-standalone rule is set in an override, skip
19
+ continue;
20
+ }
21
+ const ngEslintOverrideLookup = (o) => o.files?.includes('*.ts') &&
22
+ Object.keys(o.rules ?? {}).some((r) => r.startsWith('@angular-eslint/'));
23
+ const tsFilesOverrideLookup = (o) => o.files?.length === 1 && o.files[0] === '*.ts';
24
+ if ((0, eslint_file_1.lintConfigHasOverride)(tree, root, ngEslintOverrideLookup, false)) {
25
+ // there is an override containing an Angular ESLint rule
26
+ (0, eslint_file_1.updateOverrideInLintConfig)(tree, root, ngEslintOverrideLookup, (o) => {
27
+ o.rules = {
28
+ ...o.rules,
29
+ [preferStandaloneRule]: 'off',
30
+ };
31
+ return o;
32
+ });
33
+ }
34
+ else if ((0, eslint_file_1.lintConfigHasOverride)(tree, root, tsFilesOverrideLookup, false)) {
35
+ // there is an override for just *.ts files
36
+ (0, eslint_file_1.updateOverrideInLintConfig)(tree, root, tsFilesOverrideLookup, (o) => {
37
+ o.rules = {
38
+ ...o.rules,
39
+ [preferStandaloneRule]: 'off',
40
+ };
41
+ return o;
42
+ });
43
+ }
44
+ else {
45
+ // there are no overrides for any Angular ESLint rule or just *.ts files, add a new override
46
+ (0, eslint_file_1.addOverrideToLintConfig)(tree, root, {
47
+ files: ['*.ts'],
48
+ rules: {
49
+ [preferStandaloneRule]: 'off',
50
+ },
51
+ });
52
+ }
53
+ }
54
+ await (0, devkit_1.formatFiles)(tree);
55
+ }
@@ -24,5 +24,5 @@ export declare const tsNodeVersion = "10.9.1";
24
24
  export declare const jestPresetAngularVersion = "~14.4.0";
25
25
  export declare const typesNodeVersion = "18.16.9";
26
26
  export declare const jasmineMarblesVersion = "^0.9.2";
27
- export declare const analogVitestAngular = "~1.10.0-beta.6";
27
+ export declare const analogVitestAngular = "~1.10.0";
28
28
  export declare const jsoncEslintParserVersion = "^2.1.0";
@@ -27,5 +27,5 @@ exports.tsNodeVersion = '10.9.1';
27
27
  exports.jestPresetAngularVersion = '~14.4.0';
28
28
  exports.typesNodeVersion = '18.16.9';
29
29
  exports.jasmineMarblesVersion = '^0.9.2';
30
- exports.analogVitestAngular = '~1.10.0-beta.6';
30
+ exports.analogVitestAngular = '~1.10.0';
31
31
  exports.jsoncEslintParserVersion = '^2.1.0';
@@ -1,4 +0,0 @@
1
- import { type Schema } from '../schema';
2
- import { type ExecutorContext } from '@nx/devkit';
3
- import type { StaticRemotesConfig } from '@nx/module-federation/src/utils';
4
- export declare function buildStaticRemotes(staticRemotesConfig: StaticRemotesConfig, nxBin: any, context: ExecutorContext, options: Schema): Promise<Record<string, string>>;
@@ -1,65 +0,0 @@
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((res, rej) => {
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=build`,
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 build')) {
44
- staticProcess.stdout.removeAllListeners('data');
45
- devkit_1.logger.info(`NX Built ${staticRemotesConfig.remotes.length} static remotes`);
46
- res();
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
- rej(`Remote failed to start. A complete log can be found in: ${remoteBuildLogFile}`);
56
- }
57
- else {
58
- res();
59
- }
60
- });
61
- process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
62
- process.on('exit', () => staticProcess.kill('SIGTERM'));
63
- });
64
- return mappedLocationOfRemotes;
65
- }
@@ -1,9 +0,0 @@
1
- import { type ExecutorContext } from '@nx/devkit';
2
- import { type Schema } from '../schema';
3
- import type { StaticRemotesConfig } from '@nx/module-federation/src/utils';
4
- export declare function startStaticRemotesFileServer(staticRemotesConfig: StaticRemotesConfig, context: ExecutorContext, options: Schema): AsyncGenerator<{
5
- success: boolean;
6
- baseUrl: string;
7
- }, {
8
- success: boolean;
9
- }, unknown>;
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.startStaticRemotesFileServer = startStaticRemotesFileServer;
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 startStaticRemotesFileServer(staticRemotesConfig, context, options) {
10
- if (!staticRemotesConfig.remotes ||
11
- staticRemotesConfig.remotes.length === 0) {
12
- return;
13
- }
14
- let shouldMoveToCommonLocation = false;
15
- let commonOutputDirectory;
16
- for (const app of staticRemotesConfig.remotes) {
17
- const remoteBasePath = staticRemotesConfig.config[app].basePath;
18
- if (!commonOutputDirectory) {
19
- commonOutputDirectory = remoteBasePath;
20
- }
21
- else if (commonOutputDirectory !== remoteBasePath) {
22
- shouldMoveToCommonLocation = true;
23
- break;
24
- }
25
- }
26
- if (shouldMoveToCommonLocation) {
27
- commonOutputDirectory = (0, path_1.join)(devkit_1.workspaceRoot, 'tmp/static-remotes');
28
- for (const app of staticRemotesConfig.remotes) {
29
- const remoteConfig = staticRemotesConfig.config[app];
30
- (0, fs_1.cpSync)(remoteConfig.outputPath, (0, path_1.join)(commonOutputDirectory, remoteConfig.urlSegment), {
31
- force: true,
32
- recursive: true,
33
- });
34
- }
35
- }
36
- const staticRemotesIter = (0, file_server_impl_1.default)({
37
- cors: true,
38
- watch: false,
39
- staticFilePath: commonOutputDirectory,
40
- parallel: false,
41
- spa: false,
42
- withDeps: false,
43
- host: options.host,
44
- port: options.staticRemotesPort,
45
- ssl: options.ssl,
46
- sslCert: options.sslCert,
47
- sslKey: options.sslKey,
48
- cacheSeconds: -1,
49
- }, context);
50
- return staticRemotesIter;
51
- }
@@ -1,4 +0,0 @@
1
- import type { Schema } from '../schema';
2
- import { type ExecutorContext } from '@nx/devkit';
3
- import type { StaticRemotesConfig } from '@nx/module-federation/src/utils';
4
- export declare function buildStaticRemotes(staticRemotesConfig: StaticRemotesConfig, nxBin: any, context: ExecutorContext, options: Schema): Promise<Record<string, string>>;
@@ -1,65 +0,0 @@
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
- }
@@ -1,4 +0,0 @@
1
- import { type ExecutorContext } from '@nx/devkit';
2
- import { type Schema } from '../schema';
3
- import type { StaticRemotesConfig } from '@nx/module-federation/src/utils';
4
- export declare function startStaticRemotes(ssrStaticRemotesConfig: StaticRemotesConfig, context: ExecutorContext, options: Schema): AsyncIterable<unknown>;
@@ -1,41 +0,0 @@
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
- const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
10
- function startStaticRemotes(ssrStaticRemotesConfig, context, options) {
11
- if (ssrStaticRemotesConfig.remotes.length === 0) {
12
- return (0, async_iterable_1.createAsyncIterable)(({ next, done }) => {
13
- next({ success: true });
14
- done();
15
- });
16
- }
17
- // The directories are usually generated with /browser and /server suffixes so we need to copy them to a common directory
18
- const commonOutputDirectory = (0, path_1.join)(devkit_1.workspaceRoot, 'tmp/static-remotes');
19
- for (const app of ssrStaticRemotesConfig.remotes) {
20
- const remoteConfig = ssrStaticRemotesConfig.config[app];
21
- (0, fs_1.cpSync)(remoteConfig.outputPath, (0, path_1.join)(commonOutputDirectory, remoteConfig.urlSegment), {
22
- force: true,
23
- recursive: true,
24
- });
25
- }
26
- const staticRemotesIter = (0, file_server_impl_1.default)({
27
- cors: true,
28
- watch: false,
29
- staticFilePath: commonOutputDirectory,
30
- parallel: false,
31
- spa: false,
32
- withDeps: false,
33
- host: options.host,
34
- port: options.staticRemotesPort,
35
- ssl: options.ssl,
36
- sslCert: options.sslCert,
37
- sslKey: options.sslKey,
38
- cacheSeconds: -1,
39
- }, context);
40
- return staticRemotesIter;
41
- }