@nx/angular 24.0.0-beta.2 → 24.0.0-canary.20261016-5ef7804

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 (166) hide show
  1. package/dist/executors.d.ts +0 -2
  2. package/dist/executors.js +0 -2
  3. package/dist/generators.d.ts +0 -4
  4. package/dist/generators.js +0 -4
  5. package/dist/src/generators/application/schema.json +1 -1
  6. package/dist/src/generators/convert-to-rspack/convert-to-rspack.js +3 -3
  7. package/dist/src/generators/convert-to-rspack/lib/get-custom-webpack-config.d.ts +1 -2
  8. package/dist/src/generators/convert-to-rspack/lib/get-custom-webpack-config.js +0 -63
  9. package/dist/src/generators/convert-to-rspack/lib/validate-no-module-federation.d.ts +2 -0
  10. package/dist/src/generators/convert-to-rspack/lib/validate-no-module-federation.js +32 -0
  11. package/dist/src/generators/utils/testing.d.ts +0 -4
  12. package/dist/src/generators/utils/testing.js +0 -12
  13. package/dist/src/utils/backward-compatible-versions.js +0 -8
  14. package/dist/src/utils/versions.d.ts +0 -4
  15. package/dist/src/utils/versions.js +1 -5
  16. package/executors.json +0 -10
  17. package/generators.json +0 -35
  18. package/package.json +11 -20
  19. package/dist/.npmignore +0 -2
  20. package/dist/fesm2022/nx-angular-mf.mjs +0 -193
  21. package/dist/fesm2022/nx-angular-mf.mjs.map +0 -1
  22. package/dist/mf/package.json +0 -4
  23. package/dist/src/builders/utilities/module-federation.d.ts +0 -11
  24. package/dist/src/builders/utilities/module-federation.js +0 -109
  25. package/dist/src/executors/module-federation-dev-server/lib/index.d.ts +0 -2
  26. package/dist/src/executors/module-federation-dev-server/lib/index.js +0 -5
  27. package/dist/src/executors/module-federation-dev-server/lib/normalize-options.d.ts +0 -2
  28. package/dist/src/executors/module-federation-dev-server/lib/normalize-options.js +0 -22
  29. package/dist/src/executors/module-federation-dev-server/lib/start-dev-remotes.d.ts +0 -5
  30. package/dist/src/executors/module-federation-dev-server/lib/start-dev-remotes.js +0 -29
  31. package/dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +0 -4
  32. package/dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +0 -111
  33. package/dist/src/executors/module-federation-dev-server/schema.d.ts +0 -38
  34. package/dist/src/executors/module-federation-dev-server/schema.json +0 -171
  35. package/dist/src/executors/module-federation-ssr-dev-server/lib/normalize-options.d.ts +0 -2
  36. package/dist/src/executors/module-federation-ssr-dev-server/lib/normalize-options.js +0 -20
  37. package/dist/src/executors/module-federation-ssr-dev-server/lib/start-dev-remotes.d.ts +0 -5
  38. package/dist/src/executors/module-federation-ssr-dev-server/lib/start-dev-remotes.js +0 -30
  39. package/dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +0 -4
  40. package/dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +0 -110
  41. package/dist/src/executors/module-federation-ssr-dev-server/schema.d.ts +0 -17
  42. package/dist/src/executors/module-federation-ssr-dev-server/schema.json +0 -124
  43. package/dist/src/generators/convert-to-with-mf/convert-to-with-mf.d.ts +0 -4
  44. package/dist/src/generators/convert-to-with-mf/convert-to-with-mf.js +0 -36
  45. package/dist/src/generators/convert-to-with-mf/convert-to-with-mf.test-data.d.ts +0 -5
  46. package/dist/src/generators/convert-to-with-mf/convert-to-with-mf.test-data.js +0 -448
  47. package/dist/src/generators/convert-to-with-mf/lib/check-name-matches.d.ts +0 -2
  48. package/dist/src/generators/convert-to-with-mf/lib/check-name-matches.js +0 -22
  49. package/dist/src/generators/convert-to-with-mf/lib/check-shared-npm-packages.d.ts +0 -2
  50. package/dist/src/generators/convert-to-with-mf/lib/check-shared-npm-packages.js +0 -45
  51. package/dist/src/generators/convert-to-with-mf/lib/get-webpack-config-path.d.ts +0 -2
  52. package/dist/src/generators/convert-to-with-mf/lib/get-webpack-config-path.js +0 -18
  53. package/dist/src/generators/convert-to-with-mf/lib/index.d.ts +0 -6
  54. package/dist/src/generators/convert-to-with-mf/lib/index.js +0 -9
  55. package/dist/src/generators/convert-to-with-mf/lib/is-host-remote-config.d.ts +0 -5
  56. package/dist/src/generators/convert-to-with-mf/lib/is-host-remote-config.js +0 -57
  57. package/dist/src/generators/convert-to-with-mf/lib/parse-ast-webpack-config.d.ts +0 -2
  58. package/dist/src/generators/convert-to-with-mf/lib/parse-ast-webpack-config.js +0 -13
  59. package/dist/src/generators/convert-to-with-mf/lib/write-new-webpack-config.d.ts +0 -3
  60. package/dist/src/generators/convert-to-with-mf/lib/write-new-webpack-config.js +0 -50
  61. package/dist/src/generators/convert-to-with-mf/schema.d.ts +0 -4
  62. package/dist/src/generators/convert-to-with-mf/schema.json +0 -33
  63. package/dist/src/generators/federate-module/federate-module.d.ts +0 -4
  64. package/dist/src/generators/federate-module/federate-module.js +0 -49
  65. package/dist/src/generators/federate-module/lib/add-file-to-remote-tsconfig.d.ts +0 -2
  66. package/dist/src/generators/federate-module/lib/add-file-to-remote-tsconfig.js +0 -14
  67. package/dist/src/generators/federate-module/lib/add-path-to-exposes.d.ts +0 -8
  68. package/dist/src/generators/federate-module/lib/add-path-to-exposes.js +0 -77
  69. package/dist/src/generators/federate-module/lib/add-path-to-ts-config.d.ts +0 -8
  70. package/dist/src/generators/federate-module/lib/add-path-to-ts-config.js +0 -11
  71. package/dist/src/generators/federate-module/lib/add-remote.d.ts +0 -7
  72. package/dist/src/generators/federate-module/lib/add-remote.js +0 -42
  73. package/dist/src/generators/federate-module/lib/check-remote-exists.d.ts +0 -2
  74. package/dist/src/generators/federate-module/lib/check-remote-exists.js +0 -21
  75. package/dist/src/generators/federate-module/lib/index.d.ts +0 -4
  76. package/dist/src/generators/federate-module/lib/index.js +0 -7
  77. package/dist/src/generators/federate-module/schema.d.ts +0 -13
  78. package/dist/src/generators/federate-module/schema.json +0 -83
  79. package/dist/src/generators/host/files/common/src/main.server.ts__tmpl__ +0 -78
  80. package/dist/src/generators/host/files/js/webpack.server.config.js__tmpl__ +0 -8
  81. package/dist/src/generators/host/files/ts/webpack.server.config.ts__tmpl__ +0 -9
  82. package/dist/src/generators/host/host.d.ts +0 -4
  83. package/dist/src/generators/host/host.js +0 -133
  84. package/dist/src/generators/host/lib/index.d.ts +0 -2
  85. package/dist/src/generators/host/lib/index.js +0 -5
  86. package/dist/src/generators/host/lib/update-ssr-setup.d.ts +0 -3
  87. package/dist/src/generators/host/lib/update-ssr-setup.js +0 -54
  88. package/dist/src/generators/host/lib/validate-options.d.ts +0 -3
  89. package/dist/src/generators/host/lib/validate-options.js +0 -12
  90. package/dist/src/generators/host/schema.d.ts +0 -36
  91. package/dist/src/generators/host/schema.json +0 -195
  92. package/dist/src/generators/remote/files/base/webpack.server.config.js__tmpl__ +0 -9
  93. package/dist/src/generators/remote/files/base-ts/webpack.server.config.ts__tmpl__ +0 -9
  94. package/dist/src/generators/remote/files/common/src/main.server.ts__tmpl__ +0 -84
  95. package/dist/src/generators/remote/files/standalone/src/bootstrap.server.ts__tmpl__ +0 -12
  96. package/dist/src/generators/remote/lib/find-next-available-port.d.ts +0 -2
  97. package/dist/src/generators/remote/lib/find-next-available-port.js +0 -16
  98. package/dist/src/generators/remote/lib/index.d.ts +0 -3
  99. package/dist/src/generators/remote/lib/index.js +0 -6
  100. package/dist/src/generators/remote/lib/update-ssr-setup.d.ts +0 -9
  101. package/dist/src/generators/remote/lib/update-ssr-setup.js +0 -82
  102. package/dist/src/generators/remote/lib/validate-options.d.ts +0 -3
  103. package/dist/src/generators/remote/lib/validate-options.js +0 -12
  104. package/dist/src/generators/remote/remote.d.ts +0 -4
  105. package/dist/src/generators/remote/remote.js +0 -114
  106. package/dist/src/generators/remote/schema.d.ts +0 -34
  107. package/dist/src/generators/remote/schema.json +0 -184
  108. package/dist/src/generators/setup-mf/files/entry-module-files/__entryModuleFileName__.ts__tmpl__ +0 -18
  109. package/dist/src/generators/setup-mf/files/entry-module-files/entry.routes.ts__tmpl__ +0 -4
  110. package/dist/src/generators/setup-mf/files/entry-module-files/entry__componentFileSuffix__.ts__tmpl__ +0 -10
  111. package/dist/src/generators/setup-mf/files/host-files/__appFileName__.spec.ts__tmpl__ +0 -42
  112. package/dist/src/generators/setup-mf/files/standalone-entry-component-files/entry.routes.ts__tmpl__ +0 -4
  113. package/dist/src/generators/setup-mf/files/standalone-entry-component-files/entry__componentFileSuffix__.ts__tmpl__ +0 -11
  114. package/dist/src/generators/setup-mf/files/ts-webpack/module-federation.config.ts__tmpl__ +0 -27
  115. package/dist/src/generators/setup-mf/files/ts-webpack/tsconfig.lint.json__tmpl__ +0 -12
  116. package/dist/src/generators/setup-mf/files/ts-webpack/webpack.config.ts__tmpl__ +0 -9
  117. package/dist/src/generators/setup-mf/files/ts-webpack/webpack.prod.config.ts__tmpl__ +0 -21
  118. package/dist/src/generators/setup-mf/files/webpack/module-federation.config.js__tmpl__ +0 -23
  119. package/dist/src/generators/setup-mf/files/webpack/webpack.config.js__tmpl__ +0 -9
  120. package/dist/src/generators/setup-mf/files/webpack/webpack.prod.config.js__tmpl__ +0 -21
  121. package/dist/src/generators/setup-mf/lib/add-cypress-workaround.d.ts +0 -3
  122. package/dist/src/generators/setup-mf/lib/add-cypress-workaround.js +0 -52
  123. package/dist/src/generators/setup-mf/lib/add-remote-entry.d.ts +0 -3
  124. package/dist/src/generators/setup-mf/lib/add-remote-entry.js +0 -27
  125. package/dist/src/generators/setup-mf/lib/add-remote-to-host.d.ts +0 -9
  126. package/dist/src/generators/setup-mf/lib/add-remote-to-host.js +0 -127
  127. package/dist/src/generators/setup-mf/lib/change-build-target.d.ts +0 -3
  128. package/dist/src/generators/setup-mf/lib/change-build-target.js +0 -24
  129. package/dist/src/generators/setup-mf/lib/fix-bootstrap.d.ts +0 -3
  130. package/dist/src/generators/setup-mf/lib/fix-bootstrap.js +0 -40
  131. package/dist/src/generators/setup-mf/lib/generate-config.d.ts +0 -6
  132. package/dist/src/generators/setup-mf/lib/generate-config.js +0 -32
  133. package/dist/src/generators/setup-mf/lib/get-remotes-with-ports.d.ts +0 -6
  134. package/dist/src/generators/setup-mf/lib/get-remotes-with-ports.js +0 -20
  135. package/dist/src/generators/setup-mf/lib/index.d.ts +0 -15
  136. package/dist/src/generators/setup-mf/lib/index.js +0 -18
  137. package/dist/src/generators/setup-mf/lib/move-angular-plugin-to-dependencies.d.ts +0 -2
  138. package/dist/src/generators/setup-mf/lib/move-angular-plugin-to-dependencies.js +0 -15
  139. package/dist/src/generators/setup-mf/lib/normalize-options.d.ts +0 -3
  140. package/dist/src/generators/setup-mf/lib/normalize-options.js +0 -26
  141. package/dist/src/generators/setup-mf/lib/remove-dead-code-from-remote.d.ts +0 -3
  142. package/dist/src/generators/setup-mf/lib/remove-dead-code-from-remote.js +0 -61
  143. package/dist/src/generators/setup-mf/lib/setup-host-if-dynamic.d.ts +0 -3
  144. package/dist/src/generators/setup-mf/lib/setup-host-if-dynamic.js +0 -20
  145. package/dist/src/generators/setup-mf/lib/setup-serve-target.d.ts +0 -3
  146. package/dist/src/generators/setup-mf/lib/setup-serve-target.js +0 -39
  147. package/dist/src/generators/setup-mf/lib/setup-tspath-for-remote.d.ts +0 -3
  148. package/dist/src/generators/setup-mf/lib/setup-tspath-for-remote.js +0 -15
  149. package/dist/src/generators/setup-mf/lib/update-host-app-routes.d.ts +0 -3
  150. package/dist/src/generators/setup-mf/lib/update-host-app-routes.js +0 -39
  151. package/dist/src/generators/setup-mf/lib/update-tsconfig.d.ts +0 -3
  152. package/dist/src/generators/setup-mf/lib/update-tsconfig.js +0 -18
  153. package/dist/src/generators/setup-mf/schema.d.ts +0 -35
  154. package/dist/src/generators/setup-mf/schema.json +0 -99
  155. package/dist/src/generators/setup-mf/setup-mf.d.ts +0 -4
  156. package/dist/src/generators/setup-mf/setup-mf.js +0 -90
  157. package/dist/src/generators/utils/add-mf-env-to-inputs.d.ts +0 -2
  158. package/dist/src/generators/utils/add-mf-env-to-inputs.js +0 -36
  159. package/dist/src/generators/utils/assert-mf-utils.d.ts +0 -1
  160. package/dist/src/generators/utils/assert-mf-utils.js +0 -8
  161. package/dist/src/utils/get-mf-projects.d.ts +0 -4
  162. package/dist/src/utils/get-mf-projects.js +0 -31
  163. package/dist/src/utils/module-federation-deprecation.d.ts +0 -4
  164. package/dist/src/utils/module-federation-deprecation.js +0 -29
  165. package/dist/types/nx-angular-mf.d.ts +0 -72
  166. package/dist/types/nx-angular-mf.d.ts.map +0 -1
@@ -1,193 +0,0 @@
1
- // Helper function to extract file extension from a path
2
- function extname(path) {
3
- const lastDot = path.lastIndexOf('.');
4
- const lastSlash = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\'));
5
- if (lastDot === -1 || lastDot < lastSlash) {
6
- return '';
7
- }
8
- return path.slice(lastDot);
9
- }
10
- /**
11
- * Checks if a URL string is absolute (has protocol)
12
- */
13
- function isAbsoluteUrl(url) {
14
- try {
15
- new URL(url);
16
- return true;
17
- }
18
- catch {
19
- return false;
20
- }
21
- }
22
- /**
23
- * Safely processes remote locations, handling both relative and absolute URLs
24
- * while preserving query parameters and hash fragments for absolute URLs
25
- */
26
- function processRemoteLocation(remoteLocation, remoteEntryExt) {
27
- // Handle promise-based remotes as-is
28
- if (remoteLocation.startsWith('promise new Promise')) {
29
- return remoteLocation;
30
- }
31
- if (isAbsoluteUrl(remoteLocation)) {
32
- // Use new URL parsing for absolute URLs (supports query params/hash)
33
- const url = new URL(remoteLocation);
34
- const ext = extname(url.pathname);
35
- const needsRemoteEntry = !['.js', '.mjs', '.json'].includes(ext);
36
- if (needsRemoteEntry) {
37
- url.pathname = url.pathname.endsWith('/')
38
- ? `${url.pathname}remoteEntry.${remoteEntryExt}`
39
- : `${url.pathname}/remoteEntry.${remoteEntryExt}`;
40
- }
41
- return url.href;
42
- }
43
- else {
44
- // Use string manipulation for relative URLs (backward compatibility)
45
- const ext = extname(remoteLocation);
46
- const needsRemoteEntry = !['.js', '.mjs', '.json'].includes(ext);
47
- if (needsRemoteEntry) {
48
- const baseRemote = remoteLocation.endsWith('/')
49
- ? remoteLocation.slice(0, -1)
50
- : remoteLocation;
51
- return `${baseRemote}/remoteEntry.${remoteEntryExt}`;
52
- }
53
- return remoteLocation;
54
- }
55
- }
56
- /**
57
- * Processes remote URLs for runtime environments, resolving relative URLs against window.location.origin
58
- */
59
- function processRuntimeRemoteUrl(remoteUrl, remoteEntryExt) {
60
- if (isAbsoluteUrl(remoteUrl)) {
61
- return processRemoteLocation(remoteUrl, remoteEntryExt);
62
- }
63
- else {
64
- // For runtime relative URLs, resolve against current origin
65
- const baseUrl = typeof globalThis !== 'undefined' &&
66
- typeof globalThis.window !== 'undefined' &&
67
- globalThis.window.location
68
- ? globalThis.window.location.origin
69
- : 'http://localhost';
70
- const absoluteUrl = new URL(remoteUrl, baseUrl).href;
71
- return processRemoteLocation(absoluteUrl, remoteEntryExt);
72
- }
73
- }
74
-
75
- let resolveRemoteUrl;
76
- /**
77
- * @deprecated Use Runtime Helpers from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
78
- */
79
- function setRemoteUrlResolver(_resolveRemoteUrl) {
80
- resolveRemoteUrl = _resolveRemoteUrl;
81
- }
82
- let remoteUrlDefinitions;
83
- /**
84
- * @deprecated Use init() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
85
- * If you have a remote app called `my-remote-app` and you want to use the `http://localhost:4201/mf-manifest.json` as the remote url, you should change it from:
86
- * ```ts
87
- * import { setRemoteDefinitions } from '@nx/angular/mf';
88
- *
89
- * setRemoteDefinitions({
90
- * 'my-remote-app': 'http://localhost:4201/mf-manifest.json'
91
- * });
92
- * ```
93
- * to use init():
94
- * ```ts
95
- * import { init } from '@module-federation/enhanced/runtime';
96
- *
97
- * init({
98
- * name: 'host',
99
- * remotes: [{
100
- * name: 'my-remote-app',
101
- * entry: 'http://localhost:4201/mf-manifest.json'
102
- * }]
103
- * });
104
- * ```
105
- */
106
- function setRemoteDefinitions(definitions) {
107
- remoteUrlDefinitions = definitions;
108
- }
109
- /**
110
- * @deprecated Use registerRemotes() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
111
- * If you set a remote app with `setRemoteDefinition` such as:
112
- * ```ts
113
- * import { setRemoteDefinition } from '@nx/angular/mf';
114
- *
115
- * setRemoteDefinition(
116
- * 'my-remote-app',
117
- * 'http://localhost:4201/mf-manifest.json'
118
- * );
119
- * ```
120
- * change it to use registerRemotes():
121
- * ```ts
122
- * import { registerRemotes } from '@module-federation/enhanced/runtime';
123
- *
124
- * registerRemotes([
125
- * {
126
- * name: 'my-remote-app',
127
- * entry: 'http://localhost:4201/mf-manifest.json'
128
- * }
129
- * ]);
130
- * ```
131
- */
132
- function setRemoteDefinition(remoteName, remoteUrl) {
133
- remoteUrlDefinitions ??= {};
134
- remoteUrlDefinitions[remoteName] = remoteUrl;
135
- }
136
- let remoteModuleMap = new Map();
137
- let remoteContainerMap = new Map();
138
- /**
139
- * @deprecated Use loadRemote() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
140
- * If you set a load a remote with `loadRemoteModule` such as:
141
- * ```ts
142
- * import { loadRemoteModule } from '@nx/angular/mf';
143
- *
144
- * loadRemoteModule('my-remote-app', './Module').then(m => m.RemoteEntryModule);
145
- * ```
146
- * change it to use loadRemote():
147
- * ```ts
148
- * import { loadRemote } from '@module-federation/enhanced/runtime';
149
- *
150
- * loadRemote<typeof import('my-remote-app/Module')>('my-remote-app/Module').then(m => m.RemoteEntryModule);
151
- * ```
152
- */
153
- async function loadRemoteModule(remoteName, moduleName) {
154
- const remoteModuleKey = `${remoteName}:${moduleName}`;
155
- if (remoteModuleMap.has(remoteModuleKey)) {
156
- return remoteModuleMap.get(remoteModuleKey);
157
- }
158
- const container = remoteContainerMap.has(remoteName)
159
- ? remoteContainerMap.get(remoteName)
160
- : await loadRemoteContainer(remoteName);
161
- const factory = await container.get(moduleName);
162
- const Module = factory();
163
- remoteModuleMap.set(remoteModuleKey, Module);
164
- return Module;
165
- }
166
- function loadModule(url) {
167
- return import(/* webpackIgnore:true */ url);
168
- }
169
- let initialSharingScopeCreated = false;
170
- async function loadRemoteContainer(remoteName) {
171
- if (!resolveRemoteUrl && !remoteUrlDefinitions) {
172
- throw new Error('Call setRemoteDefinitions or setRemoteUrlResolver to allow Dynamic Federation to find the remote apps correctly.');
173
- }
174
- if (!initialSharingScopeCreated) {
175
- initialSharingScopeCreated = true;
176
- await __webpack_init_sharing__('default');
177
- }
178
- const remoteUrl = remoteUrlDefinitions
179
- ? remoteUrlDefinitions[remoteName]
180
- : await resolveRemoteUrl(remoteName);
181
- const containerUrl = processRuntimeRemoteUrl(remoteUrl, 'mjs');
182
- const container = await loadModule(containerUrl);
183
- await container.init(__webpack_share_scopes__.default);
184
- remoteContainerMap.set(remoteName, container);
185
- return container;
186
- }
187
-
188
- /**
189
- * Generated bundle index. Do not edit.
190
- */
191
-
192
- export { loadRemoteModule, setRemoteDefinition, setRemoteDefinitions, setRemoteUrlResolver };
193
- //# sourceMappingURL=nx-angular-mf.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nx-angular-mf.mjs","sources":["../../mf/url-helpers.ts","../../mf/mf.ts","../../mf/nx-angular-mf.ts"],"sourcesContent":["// Helper function to extract file extension from a path\nfunction extname(path: string): string {\n const lastDot = path.lastIndexOf('.');\n const lastSlash = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\\\'));\n if (lastDot === -1 || lastDot < lastSlash) {\n return '';\n }\n return path.slice(lastDot);\n}\n\n/**\n * Checks if a URL string is absolute (has protocol)\n */\nexport function isAbsoluteUrl(url: string): boolean {\n try {\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Safely processes remote locations, handling both relative and absolute URLs\n * while preserving query parameters and hash fragments for absolute URLs\n */\nexport function processRemoteLocation(\n remoteLocation: string,\n remoteEntryExt: 'js' | 'mjs'\n): string {\n // Handle promise-based remotes as-is\n if (remoteLocation.startsWith('promise new Promise')) {\n return remoteLocation;\n }\n\n if (isAbsoluteUrl(remoteLocation)) {\n // Use new URL parsing for absolute URLs (supports query params/hash)\n const url = new URL(remoteLocation);\n const ext = extname(url.pathname);\n const needsRemoteEntry = !['.js', '.mjs', '.json'].includes(ext);\n\n if (needsRemoteEntry) {\n url.pathname = url.pathname.endsWith('/')\n ? `${url.pathname}remoteEntry.${remoteEntryExt}`\n : `${url.pathname}/remoteEntry.${remoteEntryExt}`;\n }\n\n return url.href;\n } else {\n // Use string manipulation for relative URLs (backward compatibility)\n const ext = extname(remoteLocation);\n const needsRemoteEntry = !['.js', '.mjs', '.json'].includes(ext);\n\n if (needsRemoteEntry) {\n const baseRemote = remoteLocation.endsWith('/')\n ? remoteLocation.slice(0, -1)\n : remoteLocation;\n return `${baseRemote}/remoteEntry.${remoteEntryExt}`;\n }\n\n return remoteLocation;\n }\n}\n\n/**\n * Processes remote URLs for runtime environments, resolving relative URLs against window.location.origin\n */\nexport function processRuntimeRemoteUrl(\n remoteUrl: string,\n remoteEntryExt: 'js' | 'mjs'\n): string {\n if (isAbsoluteUrl(remoteUrl)) {\n return processRemoteLocation(remoteUrl, remoteEntryExt);\n } else {\n // For runtime relative URLs, resolve against current origin\n const baseUrl =\n typeof globalThis !== 'undefined' &&\n typeof (globalThis as any).window !== 'undefined' &&\n (globalThis as any).window.location\n ? (globalThis as any).window.location.origin\n : 'http://localhost';\n const absoluteUrl = new URL(remoteUrl, baseUrl).href;\n return processRemoteLocation(absoluteUrl, remoteEntryExt);\n }\n}\n","import { processRuntimeRemoteUrl } from './url-helpers';\n\nexport type ResolveRemoteUrlFunction = (\n remoteName: string\n) => string | Promise<string>;\n\ndeclare const __webpack_init_sharing__: (scope: 'default') => Promise<void>;\ndeclare const __webpack_share_scopes__: { default: unknown };\n\nlet resolveRemoteUrl: ResolveRemoteUrlFunction;\n\n/**\n * @deprecated Use Runtime Helpers from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.\n */\nexport function setRemoteUrlResolver(\n _resolveRemoteUrl: ResolveRemoteUrlFunction\n) {\n resolveRemoteUrl = _resolveRemoteUrl;\n}\n\nlet remoteUrlDefinitions: Record<string, string>;\n\n/**\n * @deprecated Use init() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.\n * If you have a remote app called `my-remote-app` and you want to use the `http://localhost:4201/mf-manifest.json` as the remote url, you should change it from:\n * ```ts\n * import { setRemoteDefinitions } from '@nx/angular/mf';\n *\n * setRemoteDefinitions({\n * 'my-remote-app': 'http://localhost:4201/mf-manifest.json'\n * });\n * ```\n * to use init():\n * ```ts\n * import { init } from '@module-federation/enhanced/runtime';\n *\n * init({\n * name: 'host',\n * remotes: [{\n * name: 'my-remote-app',\n * entry: 'http://localhost:4201/mf-manifest.json'\n * }]\n * });\n * ```\n */\nexport function setRemoteDefinitions(definitions: Record<string, string>) {\n remoteUrlDefinitions = definitions;\n}\n\n/**\n * @deprecated Use registerRemotes() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.\n * If you set a remote app with `setRemoteDefinition` such as:\n * ```ts\n * import { setRemoteDefinition } from '@nx/angular/mf';\n *\n * setRemoteDefinition(\n * 'my-remote-app',\n * 'http://localhost:4201/mf-manifest.json'\n * );\n * ```\n * change it to use registerRemotes():\n * ```ts\n * import { registerRemotes } from '@module-federation/enhanced/runtime';\n *\n * registerRemotes([\n * {\n * name: 'my-remote-app',\n * entry: 'http://localhost:4201/mf-manifest.json'\n * }\n * ]);\n * ```\n */\nexport function setRemoteDefinition(remoteName: string, remoteUrl: string) {\n remoteUrlDefinitions ??= {};\n remoteUrlDefinitions[remoteName] = remoteUrl;\n}\n\nlet remoteModuleMap = new Map<string, unknown>();\nlet remoteContainerMap = new Map<string, unknown>();\n\n/**\n * @deprecated Use loadRemote() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.\n * If you set a load a remote with `loadRemoteModule` such as:\n * ```ts\n * import { loadRemoteModule } from '@nx/angular/mf';\n *\n * loadRemoteModule('my-remote-app', './Module').then(m => m.RemoteEntryModule);\n * ```\n * change it to use loadRemote():\n * ```ts\n * import { loadRemote } from '@module-federation/enhanced/runtime';\n *\n * loadRemote<typeof import('my-remote-app/Module')>('my-remote-app/Module').then(m => m.RemoteEntryModule);\n * ```\n */\nexport async function loadRemoteModule(remoteName: string, moduleName: string) {\n const remoteModuleKey = `${remoteName}:${moduleName}`;\n if (remoteModuleMap.has(remoteModuleKey)) {\n return remoteModuleMap.get(remoteModuleKey);\n }\n\n const container = remoteContainerMap.has(remoteName)\n ? remoteContainerMap.get(remoteName)\n : await loadRemoteContainer(remoteName);\n\n const factory = await container.get(moduleName);\n const Module = factory();\n\n remoteModuleMap.set(remoteModuleKey, Module);\n\n return Module;\n}\n\nfunction loadModule(url: string) {\n return import(/* webpackIgnore:true */ url);\n}\n\nlet initialSharingScopeCreated = false;\n\nasync function loadRemoteContainer(remoteName: string) {\n if (!resolveRemoteUrl && !remoteUrlDefinitions) {\n throw new Error(\n 'Call setRemoteDefinitions or setRemoteUrlResolver to allow Dynamic Federation to find the remote apps correctly.'\n );\n }\n\n if (!initialSharingScopeCreated) {\n initialSharingScopeCreated = true;\n await __webpack_init_sharing__('default');\n }\n\n const remoteUrl = remoteUrlDefinitions\n ? remoteUrlDefinitions[remoteName]\n : await resolveRemoteUrl(remoteName);\n\n const containerUrl = processRuntimeRemoteUrl(remoteUrl, 'mjs');\n\n const container = await loadModule(containerUrl);\n await container.init(__webpack_share_scopes__.default);\n\n remoteContainerMap.set(remoteName, container);\n return container;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAAA;AACA,SAAS,OAAO,CAAC,IAAY,EAAA;IAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC;IACrC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACzE,IAAI,OAAO,KAAK,CAAC,CAAC,IAAI,OAAO,GAAG,SAAS,EAAE;AACzC,QAAA,OAAO,EAAE;IACX;AACA,IAAA,OAAO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M,SAAS,CAAC,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC;AAEtD,IAAA,kBAAkB,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC;AAC7C,IAAA,OAAO,SAAS;AAClB;;AC9IA;;AAEG;;;;"}
@@ -1,4 +0,0 @@
1
- {
2
- "module": "../fesm2022/nx-angular-mf.mjs",
3
- "typings": "../types/nx-angular-mf.d.ts"
4
- }
@@ -1,11 +0,0 @@
1
- import { ProjectConfiguration } from '@nx/devkit';
2
- export type DevRemoteDefinition = string | {
3
- remoteName: string;
4
- configuration: string;
5
- };
6
- export declare function getDynamicRemotes(project: ProjectConfiguration, context: import('@angular-devkit/architect').BuilderContext, workspaceProjects: Record<string, ProjectConfiguration>, remotesToSkip: Set<string>, pathToManifestFile: string | undefined): string[];
7
- export declare function getStaticRemotes(project: ProjectConfiguration, context: import('@angular-devkit/architect').BuilderContext, workspaceProjects: Record<string, ProjectConfiguration>, remotesToSkip: Set<string>): string[];
8
- export declare function validateDevRemotes(options: {
9
- devRemotes: DevRemoteDefinition[];
10
- }, workspaceProjects: Record<string, ProjectConfiguration>): void;
11
- export declare function getDynamicMfManifestFile(project: ProjectConfiguration, workspaceRoot: string): string | undefined;
@@ -1,109 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDynamicRemotes = getDynamicRemotes;
4
- exports.getStaticRemotes = getStaticRemotes;
5
- exports.validateDevRemotes = validateDevRemotes;
6
- exports.getDynamicMfManifestFile = getDynamicMfManifestFile;
7
- const devkit_1 = require("@nx/devkit");
8
- const internal_1 = require("@nx/js/internal");
9
- const fs_1 = require("fs");
10
- const path_1 = require("path");
11
- function getDynamicRemotes(project, context, workspaceProjects, remotesToSkip, pathToManifestFile) {
12
- pathToManifestFile ??= getDynamicMfManifestFile(project, context.workspaceRoot);
13
- // check for dynamic remotes
14
- // we should only check for dynamic based on what we generate
15
- // and fallback to empty array
16
- if (!pathToManifestFile || !(0, fs_1.existsSync)(pathToManifestFile)) {
17
- return [];
18
- }
19
- const moduleFederationManifestJson = (0, fs_1.readFileSync)(pathToManifestFile, 'utf-8');
20
- if (!moduleFederationManifestJson) {
21
- return [];
22
- }
23
- // This should have shape of
24
- // {
25
- // "remoteName": "remoteLocation",
26
- // }
27
- const parsedManifest = JSON.parse(moduleFederationManifestJson);
28
- if (!Object.keys(parsedManifest).every((key) => typeof key === 'string' && typeof parsedManifest[key] === 'string')) {
29
- return [];
30
- }
31
- const allDynamicRemotes = Object.entries(parsedManifest)
32
- .map(([remoteName]) => remoteName)
33
- .filter((r) => !remotesToSkip.has(r));
34
- const remotesNotInWorkspace = [];
35
- const dynamicRemotes = allDynamicRemotes.filter((remote) => {
36
- if (!workspaceProjects[remote]) {
37
- remotesNotInWorkspace.push(remote);
38
- return false;
39
- }
40
- return true;
41
- });
42
- if (remotesNotInWorkspace.length > 0) {
43
- devkit_1.logger.warn(`Skipping serving ${remotesNotInWorkspace.join(', ')} as they could not be found in the workspace. Ensure they are served correctly.`);
44
- }
45
- return dynamicRemotes;
46
- }
47
- function getModuleFederationConfig(tsconfigPath, workspaceRoot, projectRoot) {
48
- const moduleFederationConfigPathJS = (0, path_1.join)(workspaceRoot, projectRoot, 'module-federation.config.js');
49
- const moduleFederationConfigPathTS = (0, path_1.join)(workspaceRoot, projectRoot, 'module-federation.config.ts');
50
- const isTsConfig = (0, fs_1.existsSync)(moduleFederationConfigPathTS);
51
- const moduleFederationConfigPath = isTsConfig
52
- ? moduleFederationConfigPathTS
53
- : moduleFederationConfigPathJS;
54
- try {
55
- const config = isTsConfig
56
- ? (0, internal_1.loadTsFile)(moduleFederationConfigPath, (0, path_1.join)(workspaceRoot, tsconfigPath))
57
- : require(moduleFederationConfigPath);
58
- return {
59
- mfeConfig: config.default || config,
60
- mfConfigPath: moduleFederationConfigPath,
61
- };
62
- }
63
- catch {
64
- throw new Error(`Could not load ${moduleFederationConfigPath}. Was this project generated with "@nx/angular:host"?`);
65
- }
66
- }
67
- function getStaticRemotes(project, context, workspaceProjects, remotesToSkip) {
68
- const { mfeConfig, mfConfigPath } = getModuleFederationConfig(project.targets.build.options.tsConfig, context.workspaceRoot, project.root);
69
- const remotesConfig = Array.isArray(mfeConfig.remotes) && mfeConfig.remotes.length > 0
70
- ? mfeConfig.remotes
71
- : [];
72
- const allStaticRemotes = remotesConfig
73
- .map((remoteDefinition) => Array.isArray(remoteDefinition) ? remoteDefinition[0] : remoteDefinition)
74
- .filter((r) => !remotesToSkip.has(r));
75
- const remotesNotInWorkspace = [];
76
- const staticRemotes = allStaticRemotes.filter((remote) => {
77
- if (!workspaceProjects[remote]) {
78
- remotesNotInWorkspace.push(remote);
79
- return false;
80
- }
81
- return true;
82
- });
83
- if (remotesNotInWorkspace.length > 0) {
84
- devkit_1.logger.warn(`Skipping serving ${remotesNotInWorkspace.join(', ')} as they could not be found in the workspace. Ensure they are served correctly.`);
85
- }
86
- return staticRemotes;
87
- }
88
- function validateDevRemotes(options, workspaceProjects) {
89
- const invalidDevRemotes = options.devRemotes.filter((remote) => !(typeof remote === 'string'
90
- ? workspaceProjects[remote]
91
- : workspaceProjects[remote.remoteName])) ?? [];
92
- if (invalidDevRemotes.length) {
93
- throw new Error(invalidDevRemotes.length === 1
94
- ? `Invalid dev remote provided: ${invalidDevRemotes[0]}.`
95
- : `Invalid dev remotes provided: ${invalidDevRemotes.join(', ')}.`);
96
- }
97
- }
98
- function getDynamicMfManifestFile(project, workspaceRoot) {
99
- // {sourceRoot}/assets/module-federation.manifest.json was the generated
100
- // path for the manifest file in the past. We now generate the manifest
101
- // file at {root}/public/module-federation.manifest.json. This check
102
- // ensures that we can still support the old path for backwards
103
- // compatibility since old projects may still have the manifest file
104
- // at the old path.
105
- return [
106
- (0, path_1.join)(workspaceRoot, project.root, 'public/module-federation.manifest.json'),
107
- (0, path_1.join)(workspaceRoot, (0, internal_1.getProjectSourceRoot)(project), 'assets/module-federation.manifest.json'),
108
- ].find((path) => (0, fs_1.existsSync)(path));
109
- }
@@ -1,2 +0,0 @@
1
- export * from './normalize-options';
2
- export * from './start-dev-remotes';
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./normalize-options"), exports);
5
- tslib_1.__exportStar(require("./start-dev-remotes"), exports);
@@ -1,2 +0,0 @@
1
- import type { NormalizedSchema, Schema } from '../schema';
2
- export declare function normalizeOptions(schema: Schema): NormalizedSchema;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeOptions = normalizeOptions;
4
- const path_1 = require("path");
5
- const devkit_1 = require("@nx/devkit");
6
- function normalizeOptions(schema) {
7
- schema.buildLibsFromSource ??= true;
8
- process.env.NX_BUILD_LIBS_FROM_SOURCE = `${schema.buildLibsFromSource}`;
9
- process.env.NX_BUILD_TARGET = `${schema.buildTarget}`;
10
- return {
11
- ...schema,
12
- devRemotes: schema.devRemotes ?? [],
13
- host: schema.host ?? 'localhost',
14
- port: schema.port ?? 4200,
15
- liveReload: schema.liveReload ?? true,
16
- open: schema.open ?? false,
17
- ssl: schema.ssl ?? false,
18
- verbose: schema.verbose ?? false,
19
- sslCert: schema.sslCert ? (0, path_1.join)(devkit_1.workspaceRoot, schema.sslCert) : undefined,
20
- sslKey: schema.sslKey ? (0, path_1.join)(devkit_1.workspaceRoot, schema.sslKey) : undefined,
21
- };
22
- }
@@ -1,5 +0,0 @@
1
- import { type Schema } from '../schema';
2
- import { type ExecutorContext, type ProjectConfiguration } from '@nx/devkit';
3
- export declare function startRemotes(remotes: string[], workspaceProjects: Record<string, ProjectConfiguration>, options: Pick<Schema, 'devRemotes' | 'verbose'>, context: ExecutorContext, target?: 'serve' | 'serve-static'): Promise<AsyncIterable<{
4
- success: boolean;
5
- }>[]>;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.startRemotes = startRemotes;
4
- const devkit_1 = require("@nx/devkit");
5
- async function startRemotes(remotes, workspaceProjects, options, context, target = 'serve') {
6
- const remoteIters = [];
7
- for (const app of remotes) {
8
- if (!workspaceProjects[app].targets?.[target]) {
9
- throw new Error(`Could not find "${target}" target in "${app}" project.`);
10
- }
11
- else if (!workspaceProjects[app].targets?.[target].executor) {
12
- throw new Error(`Could not find executor for "${target}" target in "${app}" project.`);
13
- }
14
- const [collection, executor] = workspaceProjects[app].targets[target].executor.split(':');
15
- const isUsingModuleFederationDevServerExecutor = executor.includes('module-federation-dev-server');
16
- const configurationOverride = options.devRemotes.find((r) => typeof r !== 'string' && r.remoteName === app)?.configuration;
17
- remoteIters.push(await (0, devkit_1.runExecutor)({
18
- project: app,
19
- target,
20
- configuration: configurationOverride ?? context.configurationName,
21
- }, {
22
- ...(target === 'serve' ? { verbose: options.verbose ?? false } : {}),
23
- ...(isUsingModuleFederationDevServerExecutor
24
- ? { isInitialHost: false }
25
- : {}),
26
- }, context));
27
- }
28
- return remoteIters;
29
- }
@@ -1,4 +0,0 @@
1
- import { type ExecutorContext } from '@nx/devkit';
2
- import { type Schema } from './schema';
3
- export declare function moduleFederationDevServerExecutor(schema: Schema, context: ExecutorContext): AsyncGenerator<any, any, any>;
4
- export default moduleFederationDevServerExecutor;
@@ -1,111 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.moduleFederationDevServerExecutor = moduleFederationDevServerExecutor;
4
- const internal_1 = require("@nx/devkit/internal");
5
- const devkit_1 = require("@nx/devkit");
6
- const builder_package_1 = require("../utilities/builder-package");
7
- const lib_1 = require("./lib");
8
- const internal_2 = require("@nx/web/internal");
9
- const dev_server_impl_1 = require("../../builders/dev-server/dev-server.impl");
10
- const module_federation_1 = require("../../builders/utilities/module-federation");
11
- const path_1 = require("path");
12
- const fs_1 = require("fs");
13
- const module_federation_deprecation_1 = require("../../utils/module-federation-deprecation");
14
- const ngcli_adapter_1 = require("@nx/devkit/ngcli-adapter");
15
- // This is required to ensure that the webpack version used by the Module Federation is the same as the one used by the builders.
16
- const Module = require('module');
17
- const originalResolveFilename = Module._resolveFilename;
18
- const patchedWebpackPath = require.resolve('webpack', {
19
- paths: [require.resolve('@angular-devkit/build-angular')],
20
- });
21
- // Override the resolve function
22
- Module._resolveFilename = function (request, parent, isMain, options) {
23
- // Intercept webpack specifically
24
- if (request === 'webpack') {
25
- // Force webpack to resolve from your specific path
26
- return patchedWebpackPath;
27
- }
28
- // For all other modules, use the original resolver
29
- return originalResolveFilename.call(this, request, parent, isMain, options);
30
- };
31
- async function* moduleFederationDevServerExecutor(schema, context) {
32
- (0, builder_package_1.assertPackageIsInstalled)('@nx/module-federation', '@nx/angular:module-federation-dev-server');
33
- const { startRemoteIterators } = await import('@nx/module-federation/internal');
34
- (0, module_federation_deprecation_1.warnAngularMfDevServerExecutorDeprecation)();
35
- const options = (0, lib_1.normalizeOptions)(schema);
36
- const { projects: workspaceProjects } = (0, devkit_1.readProjectsConfigurationFromProjectGraph)(context.projectGraph);
37
- const project = workspaceProjects[context.projectName];
38
- const currIter = options.static
39
- ? (0, internal_2.fileServerExecutor)({
40
- port: options.port,
41
- host: options.host,
42
- ssl: options.ssl,
43
- buildTarget: options.buildTarget,
44
- parallel: false,
45
- spa: false,
46
- withDeps: false,
47
- cors: true,
48
- cacheSeconds: -1,
49
- }, context)
50
- : (0, internal_1.eachValueFrom)((0, dev_server_impl_1.executeDevServerBuilder)(options, await (0, ngcli_adapter_1.createBuilderContext)({
51
- builderName: '@nx/angular:webpack-browser',
52
- description: 'Build a browser application',
53
- optionSchema: require('../../builders/webpack-browser/schema.json'),
54
- }, context)));
55
- if (options.isInitialHost === false) {
56
- return yield* currIter;
57
- }
58
- let pathToManifestFile;
59
- if (!options.pathToManifestFile) {
60
- pathToManifestFile = (0, module_federation_1.getDynamicMfManifestFile)(project, context.root);
61
- }
62
- else {
63
- const userPathToManifestFile = (0, path_1.join)(context.root, options.pathToManifestFile);
64
- if (!(0, fs_1.existsSync)(userPathToManifestFile)) {
65
- throw new Error(`The provided Module Federation manifest file path does not exist. Please check the file exists at "${userPathToManifestFile}".`);
66
- }
67
- else if ((0, path_1.extname)(options.pathToManifestFile) !== '.json') {
68
- throw new Error(`The Module Federation manifest file must be a JSON. Please ensure the file at ${userPathToManifestFile} is a JSON.`);
69
- }
70
- pathToManifestFile = userPathToManifestFile;
71
- }
72
- (0, module_federation_1.validateDevRemotes)(options, workspaceProjects);
73
- const { remotes, staticRemotesIter, devRemoteIters } = await startRemoteIterators(options, context, lib_1.startRemotes, pathToManifestFile, 'angular');
74
- const removeBaseUrlEmission = (iter) => (0, internal_1.mapAsyncIterable)(iter, (v) => ({
75
- ...v,
76
- baseUrl: undefined,
77
- }));
78
- return yield* (0, internal_1.combineAsyncIterables)(removeBaseUrlEmission(currIter), ...devRemoteIters.map(removeBaseUrlEmission), ...(staticRemotesIter ? [removeBaseUrlEmission(staticRemotesIter)] : []), (0, internal_1.createAsyncIterable)(async ({ next, done }) => {
79
- if (!options.isInitialHost) {
80
- done();
81
- return;
82
- }
83
- if (remotes.remotePorts.length === 0) {
84
- devkit_1.logger.info(`NX All remotes started, server ready at http://localhost:${options.port}`);
85
- next({ success: true, baseUrl: `http://localhost:${options.port}` });
86
- done();
87
- return;
88
- }
89
- try {
90
- const portsToWaitFor = staticRemotesIter
91
- ? [options.staticRemotesPort, ...remotes.remotePorts]
92
- : [...remotes.remotePorts];
93
- await Promise.all(portsToWaitFor.map((port) => (0, internal_2.waitForPortOpen)(port, {
94
- retries: 480,
95
- retryDelay: 2500,
96
- host: 'localhost',
97
- })));
98
- devkit_1.logger.info(`NX All remotes started, server ready at http://localhost:${options.port}`);
99
- next({ success: true, baseUrl: `http://localhost:${options.port}` });
100
- }
101
- catch (err) {
102
- throw new Error(`Failed to start remotes. Check above for any errors.`, {
103
- cause: err,
104
- });
105
- }
106
- finally {
107
- done();
108
- }
109
- }));
110
- }
111
- exports.default = moduleFederationDevServerExecutor;
@@ -1,38 +0,0 @@
1
- import type { DevRemoteDefinition } from '../../builders/utilities/module-federation';
2
-
3
- interface Schema {
4
- buildTarget: string;
5
- port?: number;
6
- host?: string;
7
- proxyConfig?: string;
8
- ssl?: boolean;
9
- sslKey?: string;
10
- sslCert?: string;
11
- headers?: Record<string, string>;
12
- open?: boolean;
13
- verbose?: boolean;
14
- liveReload?: boolean;
15
- publicHost?: string;
16
- allowedHosts?: string[];
17
- servePath?: string;
18
- disableHostCheck?: boolean;
19
- hmr?: boolean;
20
- watch?: boolean;
21
- poll?: number;
22
- devRemotes?: DevRemoteDefinition[];
23
- skipRemotes?: string[];
24
- pathToManifestFile?: string;
25
- static?: boolean;
26
- isInitialHost?: boolean;
27
- parallel?: number;
28
- staticRemotesPort?: number;
29
- buildLibsFromSource?: boolean;
30
- }
31
-
32
- export type NormalizedSchema = Schema & {
33
- devRemotes: DevRemoteDefinition[];
34
- liveReload: boolean;
35
- open: boolean;
36
- ssl: boolean;
37
- verbose: boolean;
38
- };