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

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,72 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withModuleFederation = withModuleFederation;
4
- const utils_1 = require("../../utils");
5
- const utils_2 = require("./utils");
6
- const webpack_1 = require("@module-federation/enhanced/webpack");
7
- const devkit_1 = require("@nx/devkit");
8
- const is_serve_mode_1 = require("../../utils/is-serve-mode");
9
- /**
10
- * @param {ModuleFederationConfig} options
11
- */
12
- async function withModuleFederation(options, configOverride) {
13
- if (global.NX_GRAPH_CREATION) {
14
- return (config) => config;
15
- }
16
- const isDevServer = (0, is_serve_mode_1.isServeMode)();
17
- const { sharedDependencies, sharedLibraries, mappedRemotes } = await (0, utils_2.getModuleFederationConfig)(options, undefined, 'webpack');
18
- return (config, ctx) => {
19
- config.output.uniqueName = options.name;
20
- config.output.publicPath = 'auto';
21
- config.output.scriptType = 'text/javascript';
22
- config.resolve ??= {};
23
- config.resolve.modules = [
24
- ...(config.resolve.modules ?? ['node_modules']),
25
- devkit_1.workspaceRoot,
26
- ];
27
- config.optimization = {
28
- ...(config.optimization ?? {}),
29
- runtimeChunk: isDevServer && !options.exposes
30
- ? (config.optimization?.runtimeChunk ?? undefined)
31
- : false,
32
- };
33
- if (config.mode === 'development' &&
34
- Object.keys(mappedRemotes).length > 1 &&
35
- !options.exposes) {
36
- config.optimization.runtimeChunk = 'single';
37
- }
38
- config.plugins.push(new webpack_1.ModuleFederationPlugin({
39
- name: (0, utils_1.normalizeProjectName)(options.name),
40
- filename: 'remoteEntry.js',
41
- exposes: options.exposes,
42
- remotes: mappedRemotes,
43
- shared: {
44
- ...sharedDependencies,
45
- },
46
- /**
47
- * remoteType: 'script' is required for the remote to be loaded as a script tag.
48
- * remotes will need to be defined as:
49
- * { appX: 'appX@http://localhost:3001/remoteEntry.js' }
50
- * { appY: 'appY@http://localhost:3002/remoteEntry.js' }
51
- */
52
- remoteType: 'script',
53
- /**
54
- * Apply user-defined config overrides
55
- */
56
- ...(configOverride ? configOverride : {}),
57
- runtimePlugins: process.env.NX_MF_DEV_REMOTES &&
58
- !options.disableNxRuntimeLibraryControlPlugin
59
- ? [
60
- ...(configOverride?.runtimePlugins ?? []),
61
- require.resolve('@nx/module-federation/runtime-library-control-plugin'),
62
- ]
63
- : configOverride?.runtimePlugins,
64
- }), sharedLibraries.getReplacementPlugin());
65
- // The env var is only set from the module-federation-dev-server
66
- // Attach the runtime plugin
67
- config.plugins.push(new (require('webpack').DefinePlugin)({
68
- 'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
69
- }));
70
- return config;
71
- };
72
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * Checks if a URL string is absolute (has protocol)
3
- */
4
- export declare function isAbsoluteUrl(url: string): boolean;
5
- /**
6
- * Safely processes remote locations, handling both relative and absolute URLs
7
- * while preserving query parameters and hash fragments for absolute URLs
8
- */
9
- export declare function processRemoteLocation(remoteLocation: string, remoteEntryExt: 'js' | 'mjs'): string;
10
- /**
11
- * Processes remote URLs for runtime environments, resolving relative URLs against window.location.origin
12
- */
13
- export declare function processRuntimeRemoteUrl(remoteUrl: string, remoteEntryExt: 'js' | 'mjs'): string;
@@ -1,78 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isAbsoluteUrl = isAbsoluteUrl;
4
- exports.processRemoteLocation = processRemoteLocation;
5
- exports.processRuntimeRemoteUrl = processRuntimeRemoteUrl;
6
- // Browser-safe helper function to extract file extension from a path
7
- function extname(path) {
8
- const lastDot = path.lastIndexOf('.');
9
- const lastSlash = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\'));
10
- if (lastDot === -1 || lastDot < lastSlash) {
11
- return '';
12
- }
13
- return path.slice(lastDot);
14
- }
15
- /**
16
- * Checks if a URL string is absolute (has protocol)
17
- */
18
- function isAbsoluteUrl(url) {
19
- try {
20
- new URL(url);
21
- return true;
22
- }
23
- catch {
24
- return false;
25
- }
26
- }
27
- /**
28
- * Safely processes remote locations, handling both relative and absolute URLs
29
- * while preserving query parameters and hash fragments for absolute URLs
30
- */
31
- function processRemoteLocation(remoteLocation, remoteEntryExt) {
32
- // Handle promise-based remotes as-is
33
- if (remoteLocation.startsWith('promise new Promise')) {
34
- return remoteLocation;
35
- }
36
- if (isAbsoluteUrl(remoteLocation)) {
37
- // Use new URL parsing for absolute URLs (supports query params/hash)
38
- const url = new URL(remoteLocation);
39
- const ext = extname(url.pathname);
40
- const needsRemoteEntry = !['.js', '.mjs', '.json'].includes(ext);
41
- if (needsRemoteEntry) {
42
- url.pathname = url.pathname.endsWith('/')
43
- ? `${url.pathname}remoteEntry.${remoteEntryExt}`
44
- : `${url.pathname}/remoteEntry.${remoteEntryExt}`;
45
- }
46
- return url.href;
47
- }
48
- else {
49
- // Use string manipulation for relative URLs (backward compatibility)
50
- const ext = extname(remoteLocation);
51
- const needsRemoteEntry = !['.js', '.mjs', '.json'].includes(ext);
52
- if (needsRemoteEntry) {
53
- const baseRemote = remoteLocation.endsWith('/')
54
- ? remoteLocation.slice(0, -1)
55
- : remoteLocation;
56
- return `${baseRemote}/remoteEntry.${remoteEntryExt}`;
57
- }
58
- return remoteLocation;
59
- }
60
- }
61
- /**
62
- * Processes remote URLs for runtime environments, resolving relative URLs against window.location.origin
63
- */
64
- function processRuntimeRemoteUrl(remoteUrl, remoteEntryExt) {
65
- if (isAbsoluteUrl(remoteUrl)) {
66
- return processRemoteLocation(remoteUrl, remoteEntryExt);
67
- }
68
- else {
69
- // For runtime relative URLs, resolve against current origin
70
- const baseUrl = typeof globalThis !== 'undefined' &&
71
- typeof globalThis.window !== 'undefined' &&
72
- globalThis.window.location
73
- ? globalThis.window.location.origin
74
- : 'http://localhost';
75
- const absoluteUrl = new URL(remoteUrl, baseUrl).href;
76
- return processRemoteLocation(absoluteUrl, remoteEntryExt);
77
- }
78
- }
package/executors.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/schema",
3
- "executors": {}
4
- }
File without changes