@nx/module-federation 24.0.0-beta.2 → 24.0.0-beta.3

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 (131) hide show
  1. package/README.md +1 -3
  2. package/dist/angular.d.ts +1 -5
  3. package/dist/angular.js +7 -6
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.js +0 -2
  6. package/dist/rspack.d.ts +1 -5
  7. package/dist/rspack.js +7 -6
  8. package/dist/src/migrations/update-24-0-0/inventory.d.ts +11 -0
  9. package/dist/src/migrations/update-24-0-0/inventory.js +139 -0
  10. package/dist/src/migrations/update-24-0-0/migrate-angular-module-federation.d.ts +5 -0
  11. package/dist/src/migrations/update-24-0-0/migrate-angular-module-federation.js +18 -0
  12. package/dist/src/migrations/update-24-0-0/migrate-module-federation.d.ts +10 -0
  13. package/dist/src/migrations/update-24-0-0/migrate-module-federation.js +26 -0
  14. package/dist/src/migrations/update-24-0-0/migrate-module-federation.md +1931 -0
  15. package/dist/src/migrations/update-24-0-0/migrate-react-module-federation.d.ts +5 -0
  16. package/dist/src/migrations/update-24-0-0/migrate-react-module-federation.js +18 -0
  17. package/dist/src/stubs/models.d.ts +26 -0
  18. package/dist/src/stubs/stubs.d.ts +19 -0
  19. package/dist/src/stubs/stubs.js +43 -0
  20. package/dist/webpack.d.ts +1 -2
  21. package/dist/webpack.js +4 -3
  22. package/migrations.json +6 -0
  23. package/package.json +5 -60
  24. package/readme-template.md +1 -3
  25. package/dist/internal.d.ts +0 -2
  26. package/dist/internal.js +0 -13
  27. package/dist/src/executors/utils/build-static-remotes.d.ts +0 -4
  28. package/dist/src/executors/utils/build-static-remotes.js +0 -67
  29. package/dist/src/executors/utils/index.d.ts +0 -4
  30. package/dist/src/executors/utils/index.js +0 -6
  31. package/dist/src/executors/utils/models.d.ts +0 -30
  32. package/dist/src/executors/utils/start-remote-iterators.d.ts +0 -25
  33. package/dist/src/executors/utils/start-remote-iterators.js +0 -52
  34. package/dist/src/executors/utils/start-static-remotes-file-server.d.ts +0 -15
  35. package/dist/src/executors/utils/start-static-remotes-file-server.js +0 -61
  36. package/dist/src/plugins/models/index.d.ts +0 -14
  37. package/dist/src/plugins/models/index.js +0 -2
  38. package/dist/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-dev-server-plugin.d.ts +0 -13
  39. package/dist/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-dev-server-plugin.js +0 -75
  40. package/dist/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-plugin.d.ts +0 -11
  41. package/dist/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-plugin.js +0 -93
  42. package/dist/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-ssr-dev-server-plugin.d.ts +0 -15
  43. package/dist/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-ssr-dev-server-plugin.js +0 -107
  44. package/dist/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-dev-server-plugin.d.ts +0 -13
  45. package/dist/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-dev-server-plugin.js +0 -75
  46. package/dist/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-plugin.d.ts +0 -11
  47. package/dist/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-plugin.js +0 -80
  48. package/dist/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-ssr-dev-server-plugin.d.ts +0 -15
  49. package/dist/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-ssr-dev-server-plugin.js +0 -107
  50. package/dist/src/plugins/utils/build-static-remotes.d.ts +0 -3
  51. package/dist/src/plugins/utils/build-static-remotes.js +0 -65
  52. package/dist/src/plugins/utils/get-dynamic-manifest-file.d.ts +0 -2
  53. package/dist/src/plugins/utils/get-dynamic-manifest-file.js +0 -18
  54. package/dist/src/plugins/utils/get-remotes.d.ts +0 -7
  55. package/dist/src/plugins/utils/get-remotes.js +0 -68
  56. package/dist/src/plugins/utils/get-static-remotes.d.ts +0 -3
  57. package/dist/src/plugins/utils/get-static-remotes.js +0 -27
  58. package/dist/src/plugins/utils/index.d.ts +0 -7
  59. package/dist/src/plugins/utils/index.js +0 -10
  60. package/dist/src/plugins/utils/parse-remotes-config.d.ts +0 -6
  61. package/dist/src/plugins/utils/parse-remotes-config.js +0 -35
  62. package/dist/src/plugins/utils/start-remote-proxies.d.ts +0 -5
  63. package/dist/src/plugins/utils/start-remote-proxies.js +0 -65
  64. package/dist/src/plugins/utils/start-static-remotes-file-server.d.ts +0 -2
  65. package/dist/src/plugins/utils/start-static-remotes-file-server.js +0 -46
  66. package/dist/src/utils/dependencies.d.ts +0 -6
  67. package/dist/src/utils/dependencies.js +0 -70
  68. package/dist/src/utils/framework-detection.d.ts +0 -2
  69. package/dist/src/utils/framework-detection.js +0 -20
  70. package/dist/src/utils/get-remotes-for-host.d.ts +0 -17
  71. package/dist/src/utils/get-remotes-for-host.js +0 -154
  72. package/dist/src/utils/index.d.ts +0 -11
  73. package/dist/src/utils/index.js +0 -14
  74. package/dist/src/utils/is-serve-mode.d.ts +0 -2
  75. package/dist/src/utils/is-serve-mode.js +0 -19
  76. package/dist/src/utils/models/index.d.ts +0 -47
  77. package/dist/src/utils/models/index.js +0 -2
  78. package/dist/src/utils/module-federation-config.d.ts +0 -57
  79. package/dist/src/utils/module-federation-config.js +0 -144
  80. package/dist/src/utils/normalize-project-name.d.ts +0 -1
  81. package/dist/src/utils/normalize-project-name.js +0 -10
  82. package/dist/src/utils/package-json.d.ts +0 -2
  83. package/dist/src/utils/package-json.js +0 -12
  84. package/dist/src/utils/parse-static-remotes-config.d.ts +0 -13
  85. package/dist/src/utils/parse-static-remotes-config.js +0 -62
  86. package/dist/src/utils/plugins/runtime-library-control.plugin.d.ts +0 -3
  87. package/dist/src/utils/plugins/runtime-library-control.plugin.js +0 -54
  88. package/dist/src/utils/port-utils.d.ts +0 -7
  89. package/dist/src/utils/port-utils.js +0 -22
  90. package/dist/src/utils/public-api.d.ts +0 -7
  91. package/dist/src/utils/public-api.js +0 -18
  92. package/dist/src/utils/remotes.d.ts +0 -19
  93. package/dist/src/utils/remotes.js +0 -75
  94. package/dist/src/utils/rspack-version.d.ts +0 -3
  95. package/dist/src/utils/rspack-version.js +0 -11
  96. package/dist/src/utils/secondary-entry-points.d.ts +0 -12
  97. package/dist/src/utils/secondary-entry-points.js +0 -125
  98. package/dist/src/utils/share.d.ts +0 -58
  99. package/dist/src/utils/share.js +0 -334
  100. package/dist/src/utils/start-remote-proxies.d.ts +0 -5
  101. package/dist/src/utils/start-remote-proxies.js +0 -55
  102. package/dist/src/utils/start-ssr-remote-proxies.d.ts +0 -5
  103. package/dist/src/utils/start-ssr-remote-proxies.js +0 -69
  104. package/dist/src/utils/typescript.d.ts +0 -4
  105. package/dist/src/utils/typescript.js +0 -53
  106. package/dist/src/utils/url-helpers.d.ts +0 -13
  107. package/dist/src/utils/url-helpers.js +0 -70
  108. package/dist/src/with-module-federation/angular/utils.d.ts +0 -28
  109. package/dist/src/with-module-federation/angular/utils.js +0 -83
  110. package/dist/src/with-module-federation/angular/with-module-federation-ssr.d.ts +0 -2
  111. package/dist/src/with-module-federation/angular/with-module-federation-ssr.js +0 -86
  112. package/dist/src/with-module-federation/angular/with-module-federation.d.ts +0 -2
  113. package/dist/src/with-module-federation/angular/with-module-federation.js +0 -85
  114. package/dist/src/with-module-federation/react/utils.d.ts +0 -2
  115. package/dist/src/with-module-federation/react/utils.js +0 -17
  116. package/dist/src/with-module-federation/rspack/utils.d.ts +0 -10
  117. package/dist/src/with-module-federation/rspack/utils.js +0 -32
  118. package/dist/src/with-module-federation/rspack/with-module-federation-ssr.d.ts +0 -4
  119. package/dist/src/with-module-federation/rspack/with-module-federation-ssr.js +0 -75
  120. package/dist/src/with-module-federation/rspack/with-module-federation.d.ts +0 -9
  121. package/dist/src/with-module-federation/rspack/with-module-federation.js +0 -82
  122. package/dist/src/with-module-federation/webpack/utils.d.ts +0 -10
  123. package/dist/src/with-module-federation/webpack/utils.js +0 -32
  124. package/dist/src/with-module-federation/webpack/with-module-federation-ssr.d.ts +0 -2
  125. package/dist/src/with-module-federation/webpack/with-module-federation-ssr.js +0 -69
  126. package/dist/src/with-module-federation/webpack/with-module-federation.d.ts +0 -5
  127. package/dist/src/with-module-federation/webpack/with-module-federation.js +0 -72
  128. package/dist/url-helpers.d.ts +0 -13
  129. package/dist/url-helpers.js +0 -78
  130. package/executors.json +0 -4
  131. /package/dist/src/{executors/utils → stubs}/models.js +0 -0
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildStaticRemotes = buildStaticRemotes;
4
- const node_child_process_1 = require("node:child_process");
5
- const path_1 = require("path");
6
- const node_fs_1 = require("node:fs");
7
- const devkit_1 = require("@nx/devkit");
8
- const is_serve_mode_1 = require("../../utils/is-serve-mode");
9
- const internal_1 = require("@nx/devkit/internal");
10
- async function buildStaticRemotes(staticRemotesConfig, options, nxBin) {
11
- const remotes = Object.keys(staticRemotesConfig);
12
- if (!remotes.length) {
13
- return;
14
- }
15
- const mappedLocationOfRemotes = {};
16
- for (const app of remotes) {
17
- mappedLocationOfRemotes[app] = `http${options.ssl ? 's' : ''}://${options.host ?? 'localhost'}:${options.staticRemotesPort}/${staticRemotesConfig[app].urlSegment}`;
18
- }
19
- await new Promise((res, rej) => {
20
- console.log(`NX Building ${remotes.length} static remotes...`);
21
- const staticProcess = (0, node_child_process_1.fork)(nxBin, [
22
- 'run-many',
23
- `--target=build`,
24
- `--projects=${remotes.join(',')}`,
25
- ...(options.parallel ? [`--parallel=${options.parallel}`] : []),
26
- ], {
27
- cwd: devkit_1.workspaceRoot,
28
- stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
29
- env: (0, is_serve_mode_1.childBuildEnv)(),
30
- });
31
- // File to debug build failures e.g. 2024-01-01T00_00_0_0Z-build.log'
32
- const remoteBuildLogFile = (0, path_1.join)(internal_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
- console.log(stdoutString);
42
- }
43
- if (stdoutString.includes('Successfully ran target build')) {
44
- staticProcess.stdout?.removeAllListeners('data');
45
- console.info(`NX Built ${remotes.length} static remotes`);
46
- res();
47
- }
48
- });
49
- staticProcess.stderr?.on('data', (data) => console.log(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,2 +0,0 @@
1
- import { type ProjectConfiguration } from '@nx/devkit';
2
- export declare function getDynamicMfManifestFile(project: ProjectConfiguration, workspaceRoot: string): string | undefined;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDynamicMfManifestFile = getDynamicMfManifestFile;
4
- const internal_1 = require("@nx/js/internal");
5
- const fs_1 = require("fs");
6
- const path_1 = require("path");
7
- function getDynamicMfManifestFile(project, workspaceRoot) {
8
- // {sourceRoot}/assets/module-federation.manifest.json was the generated
9
- // path for the manifest file in the past. We now generate the manifest
10
- // file at {root}/public/module-federation.manifest.json. This check
11
- // ensures that we can still support the old path for backwards
12
- // compatibility since old projects may still have the manifest file
13
- // at the old path.
14
- return [
15
- (0, path_1.join)(workspaceRoot, project.root, 'public/module-federation.manifest.json'),
16
- (0, path_1.join)(workspaceRoot, (0, internal_1.getProjectSourceRoot)(project), 'assets/module-federation.manifest.json'),
17
- ].find((path) => (0, fs_1.existsSync)(path));
18
- }
@@ -1,7 +0,0 @@
1
- import { ProjectGraph } from '@nx/devkit';
2
- import { ModuleFederationConfig } from '../../utils';
3
- export declare function getRemotes(config: ModuleFederationConfig, projectGraph: ProjectGraph, pathToManifestFile?: string): {
4
- remotes: string[];
5
- remotePorts: any[];
6
- staticRemotePort: number;
7
- };
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRemotes = getRemotes;
4
- const devkit_1 = require("@nx/devkit");
5
- const utils_1 = require("../../utils");
6
- const fs_1 = require("fs");
7
- const path_1 = require("path");
8
- function getRemotes(config, projectGraph, pathToManifestFile) {
9
- const collectedRemotes = new Set();
10
- const { remotes, dynamicRemotes } = extractRemoteProjectsFromConfig(config, pathToManifestFile);
11
- remotes.forEach((r) => collectRemoteProjects(r, collectedRemotes, projectGraph));
12
- // With dynamic remotes, the manifest file may contain the names with `_` due to MF limitations on naming
13
- // The project graph might contain these names with `-` rather than `_`. Check for both.
14
- // This can occur after migration of existing remotes past Nx 19.8
15
- let normalizedDynamicRemotes = dynamicRemotes.map((r) => {
16
- if (projectGraph.nodes[r.replace(/_/g, '-')]) {
17
- return r.replace(/_/g, '-');
18
- }
19
- return r;
20
- });
21
- const knownDynamicRemotes = normalizedDynamicRemotes.filter((r) => projectGraph.nodes[r]);
22
- knownDynamicRemotes.forEach((r) => collectRemoteProjects(r, collectedRemotes, projectGraph));
23
- const remotePorts = [...collectedRemotes, ...knownDynamicRemotes].map((r) => projectGraph.nodes[r].data.targets['serve'].options.port);
24
- const staticRemotePort = Math.max(...[...remotePorts]) + 1;
25
- return {
26
- remotes: Array.from(collectedRemotes),
27
- remotePorts,
28
- staticRemotePort,
29
- };
30
- }
31
- function extractRemoteProjectsFromConfig(config, pathToManifestFile) {
32
- const remotes = [];
33
- const dynamicRemotes = [];
34
- if (pathToManifestFile && (0, fs_1.existsSync)(pathToManifestFile)) {
35
- const moduleFederationManifestJson = (0, fs_1.readFileSync)(pathToManifestFile, 'utf-8');
36
- if (moduleFederationManifestJson) {
37
- /**
38
- *
39
- * This should have shape of
40
- * {
41
- * "remoteName": "remoteLocation",
42
- * }
43
- * But users might have their own, enforce only that the key is the remote name
44
- */
45
- const parsedManifest = JSON.parse(moduleFederationManifestJson);
46
- if (Object.keys(parsedManifest).every((key) => typeof key === 'string')) {
47
- dynamicRemotes.push(...Object.keys(parsedManifest));
48
- }
49
- }
50
- }
51
- const staticRemotes = config.remotes?.map((r) => (Array.isArray(r) ? r[0] : r)) ?? [];
52
- remotes.push(...staticRemotes);
53
- return { remotes, dynamicRemotes };
54
- }
55
- function collectRemoteProjects(remote, collected, projectGraph) {
56
- const remoteProject = projectGraph.nodes[remote]?.data;
57
- if (!projectGraph.nodes[remote] || collected.has(remote)) {
58
- return;
59
- }
60
- collected.add(remote);
61
- const remoteProjectRoot = remoteProject.root;
62
- let remoteProjectTsConfig = ['tsconfig.app.json', 'tsconfig.json']
63
- .map((p) => (0, path_1.join)(devkit_1.workspaceRoot, remoteProjectRoot, p))
64
- .find((p) => (0, fs_1.existsSync)(p));
65
- const remoteProjectConfig = (0, utils_1.getModuleFederationConfig)(remoteProjectTsConfig, devkit_1.workspaceRoot, remoteProjectRoot);
66
- const { remotes: remoteProjectRemotes } = extractRemoteProjectsFromConfig(remoteProjectConfig);
67
- remoteProjectRemotes.forEach((r) => collectRemoteProjects(r, collected, projectGraph));
68
- }
@@ -1,3 +0,0 @@
1
- import { StaticRemoteConfig } from '../../utils';
2
- import { DevRemoteFindOptions } from '../models';
3
- export declare function getStaticRemotes(remotesConfig: Record<string, StaticRemoteConfig>, devRemoteFindOptions?: DevRemoteFindOptions, host?: string): Promise<Record<string, StaticRemoteConfig>>;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getStaticRemotes = getStaticRemotes;
4
- const internal_1 = require("@nx/web/internal");
5
- async function getStaticRemotes(remotesConfig, devRemoteFindOptions, host = '127.0.0.1') {
6
- const remotes = Object.keys(remotesConfig);
7
- const findStaticRemotesPromises = [];
8
- for (const remote of remotes) {
9
- findStaticRemotesPromises.push(new Promise((resolve, reject) => {
10
- (0, internal_1.waitForPortOpen)(remotesConfig[remote].port, {
11
- retries: devRemoteFindOptions?.retries ?? 3,
12
- retryDelay: devRemoteFindOptions?.retryDelay ?? 1000,
13
- host,
14
- }).then((res) => {
15
- resolve(undefined);
16
- }, (rej) => {
17
- resolve(remote);
18
- });
19
- }));
20
- }
21
- const staticRemoteNames = (await Promise.all(findStaticRemotesPromises)).filter(Boolean);
22
- let staticRemotesConfig = {};
23
- for (const remote of staticRemoteNames) {
24
- staticRemotesConfig[remote] = remotesConfig[remote];
25
- }
26
- return staticRemotesConfig;
27
- }
@@ -1,7 +0,0 @@
1
- export * from './build-static-remotes';
2
- export * from './get-dynamic-manifest-file';
3
- export * from './get-remotes';
4
- export * from './get-static-remotes';
5
- export * from './parse-remotes-config';
6
- export * from './start-remote-proxies';
7
- export * from './start-static-remotes-file-server';
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./build-static-remotes"), exports);
5
- tslib_1.__exportStar(require("./get-dynamic-manifest-file"), exports);
6
- tslib_1.__exportStar(require("./get-remotes"), exports);
7
- tslib_1.__exportStar(require("./get-static-remotes"), exports);
8
- tslib_1.__exportStar(require("./parse-remotes-config"), exports);
9
- tslib_1.__exportStar(require("./start-remote-proxies"), exports);
10
- tslib_1.__exportStar(require("./start-static-remotes-file-server"), exports);
@@ -1,6 +0,0 @@
1
- import { ProjectGraph } from '@nx/devkit';
2
- import { StaticRemoteConfig } from '../../utils';
3
- export declare function parseRemotesConfig(remotes: string[] | undefined, workspaceRoot: string, projectGraph: ProjectGraph, isServer?: boolean): {
4
- remotes: string[];
5
- config: Record<string, StaticRemoteConfig>;
6
- };
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseRemotesConfig = parseRemotesConfig;
4
- const path_1 = require("path");
5
- const devkit_1 = require("@nx/devkit");
6
- const internal_1 = require("@nx/devkit/internal");
7
- function parseRemotesConfig(remotes, workspaceRoot, projectGraph, isServer) {
8
- if (!remotes?.length) {
9
- return { remotes: [], config: undefined };
10
- }
11
- const config = {};
12
- for (const app of remotes) {
13
- const projectRoot = projectGraph.nodes[app].data.root;
14
- let outputPath = (0, internal_1.interpolate)(projectGraph.nodes[app].data.targets?.['build']?.options?.outputPath ??
15
- projectGraph.nodes[app].data.targets?.['build']?.outputs?.[0] ??
16
- `${workspaceRoot ? `${workspaceRoot}/` : ''}${projectGraph.nodes[app].data.root}/dist`, {
17
- projectName: projectGraph.nodes[app].data.name,
18
- projectRoot,
19
- workspaceRoot,
20
- });
21
- if (!outputPath.startsWith(workspaceRoot)) {
22
- outputPath = (0, devkit_1.joinPathFragments)(workspaceRoot, outputPath);
23
- }
24
- const basePath = (0, path_1.dirname)(outputPath);
25
- const urlSegment = app;
26
- const port = projectGraph.nodes[app].data.targets?.['serve']?.options.port;
27
- config[app] = {
28
- basePath,
29
- outputPath: isServer ? (0, path_1.dirname)(outputPath) : outputPath,
30
- urlSegment,
31
- port,
32
- };
33
- }
34
- return { remotes, config };
35
- }
@@ -1,5 +0,0 @@
1
- import { StaticRemoteConfig } from '../../utils';
2
- export declare function startRemoteProxies(staticRemotesConfig: Record<string, StaticRemoteConfig>, mappedLocationsOfRemotes: Record<string, string>, sslOptions?: {
3
- pathToCert: string;
4
- pathToKey: string;
5
- }, isServer?: boolean, host?: string): Promise<void>;
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.startRemoteProxies = startRemoteProxies;
4
- const utils_1 = require("../../utils");
5
- const fs_1 = require("fs");
6
- async function startRemoteProxies(staticRemotesConfig, mappedLocationsOfRemotes, sslOptions, isServer, host = '127.0.0.1') {
7
- const { createProxyMiddleware } = require('http-proxy-middleware');
8
- const express = require('express');
9
- let sslCert;
10
- let sslKey;
11
- if (sslOptions && sslOptions.pathToCert && sslOptions.pathToKey) {
12
- if ((0, fs_1.existsSync)(sslOptions.pathToCert) && (0, fs_1.existsSync)(sslOptions.pathToKey)) {
13
- sslCert = (0, fs_1.readFileSync)(sslOptions.pathToCert);
14
- sslKey = (0, fs_1.readFileSync)(sslOptions.pathToKey);
15
- }
16
- else {
17
- console.warn(`Encountered SSL options in project.json, however, the certificate files do not exist in the filesystem. Using http.`);
18
- console.warn(`Attempted to find '${sslOptions.pathToCert}' and '${sslOptions.pathToKey}'.`);
19
- }
20
- }
21
- const http = require('http');
22
- const https = require('https');
23
- const remotes = Object.keys(staticRemotesConfig);
24
- console.log(`NX Starting static remotes proxies...`);
25
- let startedProxies = 0;
26
- let skippedProxies = 0;
27
- for (const app of remotes) {
28
- const appConfig = staticRemotesConfig[app];
29
- // Check if the port is already in use (another MF dev server may have already started a proxy)
30
- const portInUse = await (0, utils_1.isPortInUse)(appConfig.port, host);
31
- if (portInUse) {
32
- console.log(`NX Skipping proxy for ${app} on port ${appConfig.port} - port already in use (likely served by another process)`);
33
- skippedProxies++;
34
- continue;
35
- }
36
- const expressProxy = express();
37
- expressProxy.use(createProxyMiddleware({
38
- target: mappedLocationsOfRemotes[app],
39
- changeOrigin: true,
40
- secure: sslCert ? false : undefined,
41
- pathRewrite: isServer
42
- ? (path) => {
43
- if (path.includes('/server')) {
44
- return path;
45
- }
46
- else {
47
- return `browser/${path}`;
48
- }
49
- }
50
- : undefined,
51
- }));
52
- const proxyServer = (sslCert ? https : http)
53
- .createServer({ cert: sslCert, key: sslKey }, expressProxy)
54
- .listen(appConfig.port);
55
- process.on('SIGTERM', () => proxyServer.close());
56
- process.on('exit', () => proxyServer.close());
57
- startedProxies++;
58
- }
59
- if (skippedProxies > 0) {
60
- console.info(`NX Static remotes proxies: started ${startedProxies}, skipped ${skippedProxies} (already running)`);
61
- }
62
- else {
63
- console.info(`NX Static remotes proxies started successfully`);
64
- }
65
- }
@@ -1,2 +0,0 @@
1
- import { StaticRemoteConfig } from '../../utils';
2
- export declare function startStaticRemotesFileServer(staticRemotesConfig: Record<string, StaticRemoteConfig>, root: string, staticRemotesPort: number): void;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.startStaticRemotesFileServer = startStaticRemotesFileServer;
4
- const path_1 = require("path");
5
- const fs_1 = require("fs");
6
- const node_child_process_1 = require("node:child_process");
7
- const devkit_1 = require("@nx/devkit");
8
- const internal_1 = require("@nx/devkit/internal");
9
- function startStaticRemotesFileServer(staticRemotesConfig, root, staticRemotesPort) {
10
- const remotes = Object.keys(staticRemotesConfig);
11
- if (!remotes || remotes.length === 0) {
12
- return;
13
- }
14
- let shouldMoveToCommonLocation = false;
15
- const commonOutputDirectory = (0, path_1.join)(devkit_1.workspaceRoot, 'tmp/static-remotes');
16
- for (const app of remotes) {
17
- const remoteConfig = staticRemotesConfig[app];
18
- if (remoteConfig) {
19
- (0, fs_1.cpSync)(remoteConfig.outputPath, (0, path_1.join)(commonOutputDirectory, remoteConfig.urlSegment), {
20
- force: true,
21
- recursive: true,
22
- });
23
- }
24
- }
25
- const { path: pathToHttpServerPkgJson, packageJson } = (0, internal_1.readModulePackageJson)('http-server', module.paths);
26
- const pathToHttpServerBin = packageJson.bin['http-server'];
27
- const pathToHttpServer = (0, path_1.resolve)(pathToHttpServerPkgJson.replace('package.json', ''), pathToHttpServerBin);
28
- const httpServerProcess = (0, node_child_process_1.fork)(pathToHttpServer, [
29
- commonOutputDirectory,
30
- `-p=${staticRemotesPort}`,
31
- `-a=localhost`,
32
- `--cors`,
33
- // disable http caching so a rebuilt static remote is not served stale
34
- // from the browser cache (see #27005, which fixed this for the executor)
35
- `-c-1`,
36
- ], {
37
- stdio: 'pipe',
38
- cwd: root,
39
- env: {
40
- FORCE_COLOR: 'true',
41
- ...process.env,
42
- },
43
- });
44
- process.on('SIGTERM', () => httpServerProcess.kill('SIGTERM'));
45
- process.on('exit', () => httpServerProcess.kill('SIGTERM'));
46
- }
@@ -1,6 +0,0 @@
1
- import type { ProjectGraph } from '@nx/devkit';
2
- import type { WorkspaceLibrary } from './models';
3
- export declare function getDependentPackagesForProject(projectGraph: ProjectGraph, name: string): {
4
- workspaceLibraries: WorkspaceLibrary[];
5
- npmPackages: string[];
6
- };
@@ -1,70 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDependentPackagesForProject = getDependentPackagesForProject;
4
- const devkit_1 = require("@nx/devkit");
5
- const internal_1 = require("@nx/js/internal");
6
- const typescript_1 = require("./typescript");
7
- function getDependentPackagesForProject(projectGraph, name) {
8
- const { npmPackages, workspaceLibraries } = collectDependencies(projectGraph, name);
9
- return {
10
- workspaceLibraries: [...workspaceLibraries.values()],
11
- npmPackages: [...npmPackages],
12
- };
13
- }
14
- function collectDependencies(projectGraph, name, dependencies = {
15
- workspaceLibraries: new Map(),
16
- npmPackages: new Set(),
17
- }, seen = new Set()) {
18
- if (seen.has(name)) {
19
- return dependencies;
20
- }
21
- seen.add(name);
22
- (projectGraph.dependencies[name] ?? []).forEach((dependency) => {
23
- if (dependency.target.startsWith('npm:')) {
24
- const npmPkg = dependency.target.replace('npm:', '');
25
- // Strip version suffix for compatibility with bun's project graph format
26
- // e.g. "@ngrx/store@21.0.1" -> "@ngrx/store"
27
- const versionIndex = npmPkg.startsWith('@')
28
- ? npmPkg.indexOf('@', 1)
29
- : npmPkg.indexOf('@');
30
- dependencies.npmPackages.add(versionIndex > 0 ? npmPkg.substring(0, versionIndex) : npmPkg);
31
- }
32
- else if (!dependency.target.includes(':')) {
33
- // Only process as workspace library if it's not an external node.
34
- // External nodes have prefixes like 'npm:', 'cargo:', etc.
35
- if (projectGraph.nodes[dependency.target]) {
36
- dependencies.workspaceLibraries.set(dependency.target, {
37
- name: dependency.target,
38
- root: projectGraph.nodes[dependency.target].data.root,
39
- importKey: getLibraryImportPath(dependency.target, projectGraph),
40
- });
41
- collectDependencies(projectGraph, dependency.target, dependencies, seen);
42
- }
43
- }
44
- // Skip other external node types (cargo:, etc.)
45
- });
46
- return dependencies;
47
- }
48
- function getLibraryImportPath(library, projectGraph) {
49
- let buildLibsFromSource = true;
50
- if (process.env.NX_BUILD_LIBS_FROM_SOURCE) {
51
- buildLibsFromSource = process.env.NX_BUILD_LIBS_FROM_SOURCE === 'true';
52
- }
53
- const libraryNode = projectGraph.nodes[library];
54
- let sourceRoots = [(0, internal_1.getProjectSourceRoot)(libraryNode.data)];
55
- if (!buildLibsFromSource && process.env.NX_BUILD_TARGET) {
56
- const buildTarget = (0, devkit_1.parseTargetString)(process.env.NX_BUILD_TARGET, projectGraph);
57
- sourceRoots = (0, devkit_1.getOutputsForTargetAndConfiguration)(buildTarget, {}, libraryNode);
58
- }
59
- const tsConfigPathMappings = (0, typescript_1.readTsPathMappings)();
60
- for (const [key, value] of Object.entries(tsConfigPathMappings)) {
61
- for (const src of sourceRoots) {
62
- if (value.find((path) => path.startsWith(src))) {
63
- return key;
64
- }
65
- }
66
- }
67
- // Return library name if not found in TS path mappings
68
- // This supports TS Solution + PM Workspaces where libs use package.json instead
69
- return library;
70
- }
@@ -1,2 +0,0 @@
1
- import type { ProjectGraph } from '@nx/devkit';
2
- export declare function isReactProject(projectName: string, projectGraph: ProjectGraph): boolean;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isReactProject = isReactProject;
4
- const dependencies_1 = require("./dependencies");
5
- function isReactProject(projectName, projectGraph) {
6
- const project = projectGraph.nodes[projectName];
7
- if (!project)
8
- return false;
9
- // Check if the project has React dependencies
10
- const { npmPackages } = (0, dependencies_1.getDependentPackagesForProject)(projectGraph, projectName);
11
- // Check for React-related packages
12
- const reactPackages = [
13
- 'react',
14
- 'react-dom',
15
- '@types/react',
16
- '@types/react-dom',
17
- ];
18
- const hasReactDependencies = reactPackages.some((pkg) => npmPackages.includes(pkg));
19
- return hasReactDependencies;
20
- }
@@ -1,17 +0,0 @@
1
- import { type ProjectConfiguration, type ProjectGraph } from '@nx/devkit';
2
- import { ModuleFederationConfig } from './models';
3
- interface ModuleFederationExecutorContext {
4
- projectName: string;
5
- projectGraph: ProjectGraph;
6
- root: string;
7
- }
8
- export declare function getBuildTargetNameFromMFDevServer(projectConfig: ProjectConfiguration, projectGraph: ProjectGraph): string;
9
- export declare function getRemotes(devRemotes: string[], skipRemotes: string[], config: ModuleFederationConfig, context: ModuleFederationExecutorContext, pathToManifestFile?: string): {
10
- staticRemotes: string[];
11
- devRemotes: any[];
12
- dynamicRemotes: any[];
13
- remotePorts: number[];
14
- staticRemotePort: number;
15
- };
16
- export declare function getModuleFederationConfig(tsconfigPath: string | undefined, workspaceRoot: string, projectRoot: string, pluginName?: 'react' | 'angular'): any;
17
- export {};