@nx/react 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 (158) hide show
  1. package/dist/index.d.ts +0 -2
  2. package/dist/index.js +1 -5
  3. package/dist/src/generators/application/files/base-rspack/rspack.config.js__tmpl__ +2 -10
  4. package/dist/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +2 -10
  5. package/dist/src/migrations/update-23-2-0/add-optional-module-federation-packages.js +2 -1
  6. package/dist/src/utils/versions.d.ts +0 -3
  7. package/dist/src/utils/versions.js +2 -5
  8. package/executors.json +1 -17
  9. package/generators.json +0 -21
  10. package/package.json +16 -47
  11. package/dist/mf/dynamic-federation.d.ts +0 -69
  12. package/dist/mf/dynamic-federation.js +0 -141
  13. package/dist/mf/index.d.ts +0 -1
  14. package/dist/mf/index.js +0 -8
  15. package/dist/module-federation.d.ts +0 -5
  16. package/dist/module-federation.js +0 -20
  17. package/dist/src/executors/module-federation-dev-server/lib/index.d.ts +0 -2
  18. package/dist/src/executors/module-federation-dev-server/lib/index.js +0 -5
  19. package/dist/src/executors/module-federation-dev-server/lib/normalize-options.d.ts +0 -4
  20. package/dist/src/executors/module-federation-dev-server/lib/normalize-options.js +0 -19
  21. package/dist/src/executors/module-federation-dev-server/lib/start-remotes.d.ts +0 -5
  22. package/dist/src/executors/module-federation-dev-server/lib/start-remotes.js +0 -33
  23. package/dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +0 -6
  24. package/dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +0 -80
  25. package/dist/src/executors/module-federation-dev-server/schema.d.ts +0 -19
  26. package/dist/src/executors/module-federation-dev-server/schema.json +0 -142
  27. package/dist/src/executors/module-federation-ssr-dev-server/lib/index.d.ts +0 -2
  28. package/dist/src/executors/module-federation-ssr-dev-server/lib/index.js +0 -5
  29. package/dist/src/executors/module-federation-ssr-dev-server/lib/normalize-options.d.ts +0 -4
  30. package/dist/src/executors/module-federation-ssr-dev-server/lib/normalize-options.js +0 -23
  31. package/dist/src/executors/module-federation-ssr-dev-server/lib/start-remotes.d.ts +0 -5
  32. package/dist/src/executors/module-federation-ssr-dev-server/lib/start-remotes.js +0 -34
  33. package/dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +0 -3
  34. package/dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +0 -83
  35. package/dist/src/executors/module-federation-ssr-dev-server/schema.d.ts +0 -29
  36. package/dist/src/executors/module-federation-ssr-dev-server/schema.json +0 -81
  37. package/dist/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts +0 -12
  38. package/dist/src/executors/module-federation-static-server/module-federation-static-server.impl.js +0 -244
  39. package/dist/src/executors/module-federation-static-server/schema.d.ts +0 -3
  40. package/dist/src/executors/module-federation-static-server/schema.json +0 -16
  41. package/dist/src/generators/federate-module/federate-module.d.ts +0 -4
  42. package/dist/src/generators/federate-module/federate-module.js +0 -67
  43. package/dist/src/generators/federate-module/lib/utils.d.ts +0 -23
  44. package/dist/src/generators/federate-module/lib/utils.js +0 -99
  45. package/dist/src/generators/federate-module/schema.d.ts +0 -15
  46. package/dist/src/generators/federate-module/schema.json +0 -89
  47. package/dist/src/generators/host/files/common/src/app/__fileName__.js__tmpl__ +0 -40
  48. package/dist/src/generators/host/files/common/src/main.js__tmpl__ +0 -13
  49. package/dist/src/generators/host/files/common/tsconfig.lint.json__tmpl__ +0 -19
  50. package/dist/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ +0 -41
  51. package/dist/src/generators/host/files/common-ts/src/main.ts__tmpl__ +0 -13
  52. package/dist/src/generators/host/files/rspack-common/src/app/__fileName__.jsx__tmpl__ +0 -42
  53. package/dist/src/generators/host/files/rspack-common/src/main.jsx__tmpl__ +0 -13
  54. package/dist/src/generators/host/files/rspack-common/tsconfig.lint.json__tmpl__ +0 -19
  55. package/dist/src/generators/host/files/rspack-module-federation/module-federation.config.js__tmpl__ +0 -24
  56. package/dist/src/generators/host/files/rspack-module-federation/rspack.config.js__tmpl__ +0 -42
  57. package/dist/src/generators/host/files/rspack-module-federation/rspack.config.prod.js__tmpl__ +0 -66
  58. package/dist/src/generators/host/files/rspack-module-federation-ssr/module-federation.server.config.js__tmpl__ +0 -27
  59. package/dist/src/generators/host/files/rspack-module-federation-ssr/rspack.config.js__tmpl__ +0 -68
  60. package/dist/src/generators/host/files/rspack-module-federation-ssr/server.ts__tmpl__ +0 -28
  61. package/dist/src/generators/host/files/rspack-module-federation-ssr/src/main.server.tsx__tmpl__ +0 -49
  62. package/dist/src/generators/host/files/rspack-module-federation-ssr/tsconfig.server.json__tmpl__ +0 -17
  63. package/dist/src/generators/host/files/rspack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +0 -22
  64. package/dist/src/generators/host/files/rspack-module-federation-ssr-ts/rspack.config.ts__tmpl__ +0 -68
  65. package/dist/src/generators/host/files/rspack-module-federation-ssr-ts/server.ts__tmpl__ +0 -28
  66. package/dist/src/generators/host/files/rspack-module-federation-ssr-ts/src/main.server.tsx__tmpl__ +0 -49
  67. package/dist/src/generators/host/files/rspack-module-federation-ssr-ts/tsconfig.server.json__tmpl__ +0 -17
  68. package/dist/src/generators/host/files/rspack-module-federation-ts/module-federation.config.ts__tmpl__ +0 -28
  69. package/dist/src/generators/host/files/rspack-module-federation-ts/rspack.config.prod.ts__tmpl__ +0 -67
  70. package/dist/src/generators/host/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +0 -42
  71. package/dist/src/generators/host/files/webpack-module-federation/module-federation.config.js__tmpl__ +0 -24
  72. package/dist/src/generators/host/files/webpack-module-federation/webpack.config.js__tmpl__ +0 -17
  73. package/dist/src/generators/host/files/webpack-module-federation/webpack.config.prod.js__tmpl__ +0 -39
  74. package/dist/src/generators/host/files/webpack-module-federation-ssr/module-federation.server.config.js__tmpl__ +0 -19
  75. package/dist/src/generators/host/files/webpack-module-federation-ssr/server.ts__tmpl__ +0 -28
  76. package/dist/src/generators/host/files/webpack-module-federation-ssr/tsconfig.server.json__tmpl__ +0 -17
  77. package/dist/src/generators/host/files/webpack-module-federation-ssr/webpack.server.config.js__tmpl__ +0 -17
  78. package/dist/src/generators/host/files/webpack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +0 -16
  79. package/dist/src/generators/host/files/webpack-module-federation-ssr-ts/server.ts__tmpl__ +0 -28
  80. package/dist/src/generators/host/files/webpack-module-federation-ssr-ts/tsconfig.server.json__tmpl__ +0 -17
  81. package/dist/src/generators/host/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +0 -17
  82. package/dist/src/generators/host/files/webpack-module-federation-ts/module-federation.config.ts__tmpl__ +0 -28
  83. package/dist/src/generators/host/files/webpack-module-federation-ts/webpack.config.prod.ts__tmpl__ +0 -40
  84. package/dist/src/generators/host/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +0 -18
  85. package/dist/src/generators/host/host.d.ts +0 -4
  86. package/dist/src/generators/host/host.js +0 -174
  87. package/dist/src/generators/host/lib/add-module-federation-files.d.ts +0 -6
  88. package/dist/src/generators/host/lib/add-module-federation-files.js +0 -92
  89. package/dist/src/generators/host/lib/normalize-host-name.d.ts +0 -2
  90. package/dist/src/generators/host/lib/normalize-host-name.js +0 -12
  91. package/dist/src/generators/host/lib/setup-ssr-for-host.d.ts +0 -6
  92. package/dist/src/generators/host/lib/setup-ssr-for-host.js +0 -59
  93. package/dist/src/generators/host/lib/update-module-federation-e2e-project.d.ts +0 -3
  94. package/dist/src/generators/host/lib/update-module-federation-e2e-project.js +0 -19
  95. package/dist/src/generators/host/lib/update-module-federation-tsconfig.d.ts +0 -3
  96. package/dist/src/generators/host/lib/update-module-federation-tsconfig.js +0 -34
  97. package/dist/src/generators/host/schema.d.ts +0 -44
  98. package/dist/src/generators/host/schema.json +0 -173
  99. package/dist/src/generators/remote/files/common/src/main.js__tmpl__ +0 -1
  100. package/dist/src/generators/remote/files/common/src/remote-entry.js__tmpl__ +0 -1
  101. package/dist/src/generators/remote/files/common-ts/src/main.ts__tmpl__ +0 -1
  102. package/dist/src/generators/remote/files/common-ts/src/remote-entry.ts__tmpl__ +0 -1
  103. package/dist/src/generators/remote/files/rspack-common/src/main.jsx__tmpl__ +0 -1
  104. package/dist/src/generators/remote/files/rspack-common/src/remote-entry.js__tmpl__ +0 -1
  105. package/dist/src/generators/remote/files/rspack-module-federation/module-federation.config.js__tmpl__ +0 -12
  106. package/dist/src/generators/remote/files/rspack-module-federation/rspack.config.js__tmpl__ +0 -45
  107. package/dist/src/generators/remote/files/rspack-module-federation/rspack.config.prod.js__tmpl__ +0 -1
  108. package/dist/src/generators/remote/files/rspack-module-federation-ssr/module-federation.server.config.js__tmpl__ +0 -15
  109. package/dist/src/generators/remote/files/rspack-module-federation-ssr/rspack.config.js__tmpl__ +0 -71
  110. package/dist/src/generators/remote/files/rspack-module-federation-ssr/server.ts__tmpl__ +0 -45
  111. package/dist/src/generators/remote/files/rspack-module-federation-ssr/src/main.server.tsx__tmpl__ +0 -45
  112. package/dist/src/generators/remote/files/rspack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +0 -19
  113. package/dist/src/generators/remote/files/rspack-module-federation-ssr-ts/rspack.config.ts__tmpl__ +0 -71
  114. package/dist/src/generators/remote/files/rspack-module-federation-ssr-ts/server.ts__tmpl__ +0 -45
  115. package/dist/src/generators/remote/files/rspack-module-federation-ssr-ts/src/main.server.tsx__tmpl__ +0 -45
  116. package/dist/src/generators/remote/files/rspack-module-federation-ssr-ts/tsconfig.lint.json__tmpl__ +0 -19
  117. package/dist/src/generators/remote/files/rspack-module-federation-ts/module-federation.config.ts__tmpl__ +0 -16
  118. package/dist/src/generators/remote/files/rspack-module-federation-ts/rspack.config.prod.ts__tmpl__ +0 -1
  119. package/dist/src/generators/remote/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +0 -45
  120. package/dist/src/generators/remote/files/rspack-module-federation-ts/tsconfig.lint.json__tmpl__ +0 -19
  121. package/dist/src/generators/remote/files/webpack-module-federation/module-federation.config.js__tmpl__ +0 -12
  122. package/dist/src/generators/remote/files/webpack-module-federation/webpack.config.js__tmpl__ +0 -17
  123. package/dist/src/generators/remote/files/webpack-module-federation/webpack.config.prod.js__tmpl__ +0 -1
  124. package/dist/src/generators/remote/files/webpack-module-federation-ssr/module-federation.server.config.js__tmpl__ +0 -9
  125. package/dist/src/generators/remote/files/webpack-module-federation-ssr/server.ts__tmpl__ +0 -45
  126. package/dist/src/generators/remote/files/webpack-module-federation-ssr/webpack.server.config.js__tmpl__ +0 -17
  127. package/dist/src/generators/remote/files/webpack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +0 -13
  128. package/dist/src/generators/remote/files/webpack-module-federation-ssr-ts/server.ts__tmpl__ +0 -45
  129. package/dist/src/generators/remote/files/webpack-module-federation-ssr-ts/tsconfig.lint.json__tmpl__ +0 -19
  130. package/dist/src/generators/remote/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +0 -17
  131. package/dist/src/generators/remote/files/webpack-module-federation-ts/module-federation.config.ts__tmpl__ +0 -16
  132. package/dist/src/generators/remote/files/webpack-module-federation-ts/tsconfig.lint.json__tmpl__ +0 -19
  133. package/dist/src/generators/remote/files/webpack-module-federation-ts/webpack.config.prod.ts__tmpl__ +0 -1
  134. package/dist/src/generators/remote/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +0 -17
  135. package/dist/src/generators/remote/lib/add-remote-to-dynamic-host.d.ts +0 -2
  136. package/dist/src/generators/remote/lib/add-remote-to-dynamic-host.js +0 -12
  137. package/dist/src/generators/remote/lib/setup-package-json-exports-for-remote.d.ts +0 -3
  138. package/dist/src/generators/remote/lib/setup-package-json-exports-for-remote.js +0 -30
  139. package/dist/src/generators/remote/lib/setup-ssr-for-remote.d.ts +0 -4
  140. package/dist/src/generators/remote/lib/setup-ssr-for-remote.js +0 -61
  141. package/dist/src/generators/remote/lib/setup-tspath-for-remote.d.ts +0 -3
  142. package/dist/src/generators/remote/lib/setup-tspath-for-remote.js +0 -14
  143. package/dist/src/generators/remote/lib/update-host-with-remote.d.ts +0 -2
  144. package/dist/src/generators/remote/lib/update-host-with-remote.js +0 -79
  145. package/dist/src/generators/remote/remote.d.ts +0 -6
  146. package/dist/src/generators/remote/remote.js +0 -201
  147. package/dist/src/generators/remote/schema.d.ts +0 -39
  148. package/dist/src/generators/remote/schema.json +0 -173
  149. package/dist/src/module-federation/ast-utils.d.ts +0 -8
  150. package/dist/src/module-federation/ast-utils.js +0 -101
  151. package/dist/src/rules/update-module-federation-project.d.ts +0 -11
  152. package/dist/src/rules/update-module-federation-project.js +0 -72
  153. package/dist/src/utils/add-mf-env-to-inputs.d.ts +0 -2
  154. package/dist/src/utils/add-mf-env-to-inputs.js +0 -29
  155. package/dist/src/utils/module-federation-deprecation.d.ts +0 -12
  156. package/dist/src/utils/module-federation-deprecation.js +0 -46
  157. package/dist/src/utils/normalize-remote.d.ts +0 -8
  158. package/dist/src/utils/normalize-remote.js +0 -31
@@ -1,28 +0,0 @@
1
- import type { ModuleFederationConfig } from '@nx/module-federation';
2
-
3
- const config: ModuleFederationConfig = {
4
- name: '<%= projectName %>',
5
- /**
6
- * To use a remote that does not exist in your current Nx Workspace
7
- * You can use the tuple-syntax to define your remote
8
- *
9
- * remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
10
- *
11
- * You _may_ need to add a `remotes.d.ts` file to your `src/` folder declaring the external remote for tsc, with the
12
- * following content:
13
- *
14
- * declare module 'my-external-remote';
15
- *
16
- */
17
- remotes: [
18
- <%_ if (static) {
19
- remotes.forEach(function(r) { _%>
20
- "<%= r.fileName %>",
21
- <%_ }); } _%>
22
- ],
23
- };
24
-
25
- /**
26
- * Nx requires a default export of the config to allow correct resolution of the module federation graph.
27
- **/
28
- export default config;
@@ -1,67 +0,0 @@
1
- import { NxAppRspackPlugin } from '@nx/rspack/app-plugin.js';
2
- import { NxReactRspackPlugin } from '@nx/rspack/react-plugin.js';
3
- import { NxModuleFederationPlugin, NxModuleFederationDevServerPlugin } from '@nx/module-federation/rspack';
4
- import type { ModuleFederationConfig } from '@nx/module-federation';
5
- import { join } from 'path';
6
-
7
- import baseConfig from './module-federation.config';
8
-
9
- const prodConfig: ModuleFederationConfig = {
10
- ...baseConfig,
11
- /*
12
- * Remote overrides for production.
13
- * Each entry is a pair of a unique name and the URL where it is deployed.
14
- *
15
- * e.g.
16
- * remotes: [
17
- * ['app1', 'http://app1.example.com'],
18
- * ['app2', 'http://app2.example.com'],
19
- * ]
20
- *
21
- * You can also use a full path to the remoteEntry.js file if desired.
22
- *
23
- * remotes: [
24
- * ['app1', 'http://example.com/path/to/app1/remoteEntry.js'],
25
- * ['app2', 'http://example.com/path/to/app2/remoteEntry.js'],
26
- * ]
27
- */
28
- remotes: [
29
- <%_ remotes.forEach(function(r) { _%>
30
- ['<%= r.fileName %>', 'http://localhost:<%= r.port %>/'],
31
- <%_ }); _%>
32
- ],
33
- };
34
-
35
- export default {
36
- output: {
37
- path: join(__dirname, '<%= rspackPluginOptions.outputPath %>'),
38
- publicPath: 'auto'
39
- },
40
- devServer: {
41
- port: <%= port %>,
42
- historyApiFallback: {
43
- index: '/index.html',
44
- disableDotRule: true,
45
- htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'],
46
- },
47
- },
48
- plugins: [
49
- new NxAppRspackPlugin({
50
- tsConfig: '<%= rspackPluginOptions.tsConfig %>',
51
- main: '<%= rspackPluginOptions.main %>',
52
- index: '<%= rspackPluginOptions.index %>',
53
- baseHref: '<%= rspackPluginOptions.baseHref %>',
54
- assets: <%- JSON.stringify(rspackPluginOptions.assets) %>,
55
- styles: <%- JSON.stringify(rspackPluginOptions.styles) %>,
56
- outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none',
57
- optimization: process.env['NODE_ENV'] === 'production',
58
- }),
59
- new NxReactRspackPlugin({
60
- // Uncomment this line if you don't want to use SVGR
61
- // See: https://react-svgr.com/
62
- // svgr: false
63
- }),
64
- new NxModuleFederationPlugin({ config: prodConfig }, { dts: false }),
65
- new NxModuleFederationDevServerPlugin({ config: prodConfig }),
66
- ],
67
- };
@@ -1,42 +0,0 @@
1
- import { NxAppRspackPlugin } from '@nx/rspack/app-plugin.js';
2
- import { NxReactRspackPlugin } from '@nx/rspack/react-plugin.js';
3
- import { NxModuleFederationPlugin, NxModuleFederationDevServerPlugin } from '@nx/module-federation/rspack';
4
- import { join } from 'path';
5
-
6
- import config from './module-federation.config';
7
-
8
- export default {
9
- // rspack-cli dev mode defaults this on; it breaks module federation.
10
- lazyCompilation: false,
11
- output: {
12
- path: join(__dirname, '<%= rspackPluginOptions.outputPath %>'),
13
- publicPath: 'auto'
14
- },
15
- devServer: {
16
- port: <%= port %>,
17
- historyApiFallback: {
18
- index: '/index.html',
19
- disableDotRule: true,
20
- htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'],
21
- },
22
- },
23
- plugins: [
24
- new NxAppRspackPlugin({
25
- tsConfig: '<%= rspackPluginOptions.tsConfig %>',
26
- main: '<%= rspackPluginOptions.main %>',
27
- index: '<%= rspackPluginOptions.index %>',
28
- baseHref: '<%= rspackPluginOptions.baseHref %>',
29
- assets: <%- JSON.stringify(rspackPluginOptions.assets) %>,
30
- styles: <%- JSON.stringify(rspackPluginOptions.styles) %>,
31
- outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none',
32
- optimization: process.env['NODE_ENV'] === 'production',
33
- }),
34
- new NxReactRspackPlugin({
35
- // Uncomment this line if you don't want to use SVGR
36
- // See: https://react-svgr.com/
37
- // svgr: false
38
- }),
39
- new NxModuleFederationPlugin({ config }, { dts: false }),
40
- new NxModuleFederationDevServerPlugin({ config }),
41
- ],
42
- };
@@ -1,24 +0,0 @@
1
- /**
2
- * Nx requires a default export of the config to allow correct resolution of the module federation graph.
3
- **/
4
- module.exports = {
5
- name: '<%= projectName %>',
6
- /**
7
- * To use a remote that does not exist in your current Nx Workspace
8
- * You can use the tuple-syntax to define your remote
9
- *
10
- * remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
11
- *
12
- * You _may_ need to add a `remotes.d.ts` file to your `src/` folder declaring the external remote for tsc, with the
13
- * following content:
14
- *
15
- * declare module 'my-external-remote';
16
- *
17
- */
18
- remotes: [
19
- <%_ if (static) {
20
- remotes.forEach(function(r) { _%>
21
- "<%= r.fileName %>",
22
- <%_ }); } _%>
23
- ],
24
- };
@@ -1,17 +0,0 @@
1
- const { composePlugins, withNx } = require('@nx/webpack');
2
- const { withReact } = require('@nx/react');
3
- const { withModuleFederation } = require('@nx/module-federation/webpack');
4
-
5
- const baseConfig = require('./module-federation.config');
6
-
7
- const config = {
8
- ...baseConfig,
9
- };
10
-
11
- // Nx plugins for webpack to build config object from Nx options and context.
12
- /**
13
- * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
14
- * The DTS Plugin can be enabled by setting dts: true
15
- * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
16
- */
17
- module.exports = composePlugins(withNx(), withReact(), withModuleFederation(config, { dts: false }));
@@ -1,39 +0,0 @@
1
- const { composePlugins, withNx } = require('@nx/webpack');
2
- const { withReact } = require('@nx/react');
3
- const { withModuleFederation } = require('@nx/module-federation/webpack');
4
-
5
- const baseConfig = require('./module-federation.config');
6
-
7
- const prodConfig = {
8
- ...baseConfig,
9
- /*
10
- * Remote overrides for production.
11
- * Each entry is a pair of a unique name and the URL where it is deployed.
12
- *
13
- * e.g.
14
- * remotes: [
15
- * ['app1', 'http://app1.example.com'],
16
- * ['app2', 'http://app2.example.com'],
17
- * ]
18
- *
19
- * You can also use a full path to the remoteEntry.js file if desired.
20
- *
21
- * remotes: [
22
- * ['app1', 'http://example.com/path/to/app1/remoteEntry.js'],
23
- * ['app2', 'http://example.com/path/to/app2/remoteEntry.js'],
24
- * ]
25
- */
26
- remotes: [
27
- <%_ remotes.forEach(function(r) { _%>
28
- ['<%= r.fileName %>', 'http://localhost:<%= r.port %>/'],
29
- <%_ }); _%>
30
- ],
31
- };
32
-
33
- // Nx plugins for webpack to build config object from Nx options and context.
34
- /**
35
- * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
36
- * The DTS Plugin can be enabled by setting dts: true
37
- * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
38
- */
39
- module.exports = composePlugins(withNx(), withReact(), withModuleFederation(prodConfig, { dts: false }));
@@ -1,19 +0,0 @@
1
- // @ts-check
2
-
3
- /**
4
- * @type {import('@nx/module-federation').ModuleFederationConfig}
5
- **/
6
- const moduleFederationConfig = {
7
- name: '<%= projectName %>',
8
- remotes: [
9
- <%_ if (static) {
10
- remotes.forEach(function(r) { _%>
11
- "<%= r.fileName %>",
12
- <%_ }); } _%>
13
- ],
14
- };
15
-
16
- /**
17
- * Nx requires a default export of the config to allow correct resolution of the module federation graph.
18
- **/
19
- module.exports = moduleFederationConfig;
@@ -1,28 +0,0 @@
1
- import * as path from 'path';
2
- import express from 'express';
3
- import cors from 'cors';
4
-
5
- import { handleRequest } from './src/main.server';
6
-
7
- const port = process.env['PORT'] || <%= port %>;
8
- const app = express();
9
-
10
- const browserDist = path.join(process.cwd(), '<%= browserBuildOutputPath %>');
11
- const indexPath = path.join(browserDist, 'index.html');
12
-
13
- app.use(cors());
14
-
15
- app.get(
16
- '*.*',
17
- express.static(browserDist, {
18
- maxAge: '1y',
19
- })
20
- );
21
-
22
- app.use('*', handleRequest(indexPath));
23
-
24
- const server = app.listen(port, () => {
25
- console.log(`Express server listening on http://localhost:${port}`);
26
- });
27
-
28
- server.on('error', console.error);
@@ -1,17 +0,0 @@
1
- {
2
- "extends": "./tsconfig.app.json",
3
- "compilerOptions": {
4
- "outDir": "../../out-tsc/server",
5
- "target": "es2019",
6
- "types": [
7
- "node",
8
- "@nx/react/typings/cssmodule.d.ts",
9
- "@nx/react/typings/image.d.ts"
10
- ]
11
- },
12
- "include": [
13
- "src/remotes.d.ts",
14
- "src/main.server.tsx",
15
- "server.ts"
16
- ]
17
- }
@@ -1,17 +0,0 @@
1
- const {composePlugins, withNx} = require('@nx/webpack');
2
- const {withReact} = require('@nx/react');
3
- const {withModuleFederationForSSR} = require('@nx/module-federation/webpack');
4
-
5
- const baseConfig = require('./module-federation.config');
6
-
7
- const defaultConfig = {
8
- ...baseConfig
9
- };
10
-
11
- // Nx plugins for webpack to build config object from Nx options and context.
12
- /**
13
- * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
14
- * The DTS Plugin can be enabled by setting dts: true
15
- * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
16
- */
17
- module.exports = composePlugins(withNx(), withReact({ssr: true}), withModuleFederationForSSR(defaultConfig, { dts: false }));
@@ -1,16 +0,0 @@
1
- import type { ModuleFederationConfig } from '@nx/module-federation';
2
-
3
- const config: ModuleFederationConfig = {
4
- name: '<%= projectName %>',
5
- remotes: [
6
- <%_ if (static) {
7
- remotes.forEach(function(r) { _%>
8
- "<%= r.fileName %>",
9
- <%_ }); } _%>
10
- ],
11
- };
12
-
13
- /**
14
- * Nx requires a default export of the config to allow correct resolution of the module federation graph.
15
- **/
16
- export default config;
@@ -1,28 +0,0 @@
1
- import * as path from 'path';
2
- import express from 'express';
3
- import cors from 'cors';
4
-
5
- import { handleRequest } from './src/main.server';
6
-
7
- const port = process.env['PORT'] || <%= port %>;
8
- const app = express();
9
-
10
- const browserDist = path.join(process.cwd(), '<%= browserBuildOutputPath %>');
11
- const indexPath = path.join(browserDist, 'index.html');
12
-
13
- app.use(cors());
14
-
15
- app.get(
16
- '*.*',
17
- express.static(browserDist, {
18
- maxAge: '1y',
19
- })
20
- );
21
-
22
- app.use('*', handleRequest(indexPath));
23
-
24
- const server = app.listen(port, () => {
25
- console.log(`Express server listening on http://localhost:${port}`);
26
- });
27
-
28
- server.on('error', console.error);
@@ -1,17 +0,0 @@
1
- {
2
- "extends": "./tsconfig.app.json",
3
- "compilerOptions": {
4
- "outDir": "../../out-tsc/server",
5
- "target": "es2019",
6
- "types": [
7
- "node",
8
- "@nx/react/typings/cssmodule.d.ts",
9
- "@nx/react/typings/image.d.ts"
10
- ]
11
- },
12
- "include": [
13
- "src/remotes.d.ts",
14
- "src/main.server.tsx",
15
- "server.ts"
16
- ]
17
- }
@@ -1,17 +0,0 @@
1
- import {composePlugins, withNx} from '@nx/webpack';
2
- import {withReact} from '@nx/react';
3
- import {withModuleFederationForSSR} from '@nx/module-federation/webpack';
4
-
5
- import baseConfig from './module-federation.config';
6
-
7
- const defaultConfig = {
8
- ...baseConfig
9
- };
10
-
11
- // Nx plugins for webpack to build config object from Nx options and context.
12
- /**
13
- * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
14
- * The DTS Plugin can be enabled by setting dts: true
15
- * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
16
- */
17
- export default composePlugins(withNx(), withReact({ssr: true}), withModuleFederationForSSR(defaultConfig, { dts: false }));
@@ -1,28 +0,0 @@
1
- import type { ModuleFederationConfig } from '@nx/module-federation';
2
-
3
- const config: ModuleFederationConfig = {
4
- name: '<%= projectName %>',
5
- /**
6
- * To use a remote that does not exist in your current Nx Workspace
7
- * You can use the tuple-syntax to define your remote
8
- *
9
- * remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
10
- *
11
- * You _may_ need to add a `remotes.d.ts` file to your `src/` folder declaring the external remote for tsc, with the
12
- * following content:
13
- *
14
- * declare module 'my-external-remote';
15
- *
16
- */
17
- remotes: [
18
- <%_ if (static) {
19
- remotes.forEach(function(r) { _%>
20
- "<%= r.fileName %>",
21
- <%_ }); } _%>
22
- ],
23
- };
24
-
25
- /**
26
- * Nx requires a default export of the config to allow correct resolution of the module federation graph.
27
- **/
28
- export default config;
@@ -1,40 +0,0 @@
1
- import { composePlugins, withNx } from '@nx/webpack';
2
- import { withReact } from '@nx/react';
3
- import { withModuleFederation } from '@nx/module-federation/webpack';
4
- import type { ModuleFederationConfig } from '@nx/module-federation';
5
-
6
- import baseConfig from './module-federation.config';
7
-
8
- const prodConfig: ModuleFederationConfig = {
9
- ...baseConfig,
10
- /*
11
- * Remote overrides for production.
12
- * Each entry is a pair of a unique name and the URL where it is deployed.
13
- *
14
- * e.g.
15
- * remotes: [
16
- * ['app1', 'http://app1.example.com'],
17
- * ['app2', 'http://app2.example.com'],
18
- * ]
19
- *
20
- * You can also use a full path to the remoteEntry.js file if desired.
21
- *
22
- * remotes: [
23
- * ['app1', 'http://example.com/path/to/app1/remoteEntry.js'],
24
- * ['app2', 'http://example.com/path/to/app2/remoteEntry.js'],
25
- * ]
26
- */
27
- remotes: [
28
- <%_ remotes.forEach(function(r) { _%>
29
- ['<%= r.fileName %>', 'http://localhost:<%= r.port %>/'],
30
- <%_ }); _%>
31
- ],
32
- };
33
-
34
- // Nx plugins for webpack to build config object from Nx options and context.
35
- /**
36
- * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
37
- * The DTS Plugin can be enabled by setting dts: true
38
- * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
39
- */
40
- export default composePlugins(withNx(), withReact(), withModuleFederation(prodConfig, { dts: false }));
@@ -1,18 +0,0 @@
1
- import {composePlugins, withNx} from '@nx/webpack';
2
- import {withReact} from '@nx/react';
3
- import {withModuleFederation} from '@nx/module-federation/webpack';
4
- import type { ModuleFederationConfig } from '@nx/module-federation';
5
-
6
- import baseConfig from './module-federation.config';
7
-
8
- const config: ModuleFederationConfig = {
9
- ...baseConfig,
10
- };
11
-
12
- // Nx plugins for webpack to build config object from Nx options and context.
13
- /**
14
- * DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
15
- * The DTS Plugin can be enabled by setting dts: true
16
- * Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
17
- */
18
- export default composePlugins(withNx(), withReact(), withModuleFederation(config, { dts: false }));
@@ -1,4 +0,0 @@
1
- import { GeneratorCallback, Tree } from '@nx/devkit';
2
- import { Schema } from './schema';
3
- export declare function hostGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
4
- export default hostGenerator;
@@ -1,174 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hostGenerator = hostGenerator;
4
- const tslib_1 = require("tslib");
5
- const internal_1 = require("@nx/devkit/internal");
6
- const assert_supported_react_version_1 = require("../../utils/assert-supported-react-version");
7
- const internal_2 = require("@nx/eslint/internal");
8
- const devkit_1 = require("@nx/devkit");
9
- const update_module_federation_project_1 = require("../../rules/update-module-federation-project");
10
- const application_1 = tslib_1.__importDefault(require("../application/application"));
11
- const normalize_options_1 = require("../application/lib/normalize-options");
12
- const remote_1 = tslib_1.__importDefault(require("../remote/remote"));
13
- const setup_ssr_1 = tslib_1.__importDefault(require("../setup-ssr/setup-ssr"));
14
- const add_module_federation_files_1 = require("./lib/add-module-federation-files");
15
- const normalize_remote_1 = require("../../utils/normalize-remote");
16
- const setup_ssr_for_host_1 = require("./lib/setup-ssr-for-host");
17
- const update_module_federation_e2e_project_1 = require("./lib/update-module-federation-e2e-project");
18
- const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
19
- const js_1 = require("@nx/js");
20
- const internal_3 = require("@nx/js/internal");
21
- const versions_1 = require("../../utils/versions");
22
- const update_module_federation_tsconfig_1 = require("./lib/update-module-federation-tsconfig");
23
- const normalize_host_name_1 = require("./lib/normalize-host-name");
24
- const module_federation_deprecation_1 = require("../../utils/module-federation-deprecation");
25
- async function hostGenerator(host, schema) {
26
- (0, assert_supported_react_version_1.assertSupportedReactVersion)(host);
27
- (0, module_federation_deprecation_1.warnReactHostGeneratorDeprecation)();
28
- const tasks = [];
29
- const name = await (0, normalize_host_name_1.normalizeHostName)(host, schema.directory, schema.name);
30
- const options = {
31
- ...(await (0, normalize_options_1.normalizeOptions)(host, {
32
- ...schema,
33
- name,
34
- })),
35
- js: schema.js ?? false,
36
- typescriptConfiguration: schema.js
37
- ? false
38
- : (schema.typescriptConfiguration ?? true),
39
- dynamic: schema.dynamic ?? false,
40
- // TODO(colum): remove when Webpack MF works with Crystal
41
- addPlugin: !schema.bundler || schema.bundler === 'rspack' ? true : false,
42
- bundler: schema.bundler ?? 'rspack',
43
- // The schema carries no default, so supply one here: remotes are numbered up
44
- // from the host's port (`options.port + 1` below), which needs a concrete value.
45
- port: schema.port ?? schema.devServerPort ?? 4200,
46
- };
47
- // Check to see if remotes are provided and also check if --dynamic is provided
48
- // if both are check that the remotes are valid names else throw an error.
49
- if (options.dynamic && options.remotes?.length > 0) {
50
- options.remotes.forEach((remote) => {
51
- const isValidRemote = (0, js_1.isValidVariable)(remote);
52
- if (!isValidRemote.isValid) {
53
- throw new Error(`Invalid remote name provided: ${remote}. ${isValidRemote.message}`);
54
- }
55
- });
56
- }
57
- await (0, internal_1.ensureRootProjectName)(options, 'application');
58
- const initTask = await (0, application_1.default)(host, {
59
- ...options,
60
- directory: options.appProjectRoot,
61
- name: options.name,
62
- // The target use-case is loading remotes as child routes, thus always enable routing.
63
- routing: true,
64
- skipFormat: true,
65
- });
66
- tasks.push(initTask);
67
- // In TS solution setup, update package.json to use simple name instead of scoped name
68
- if ((0, internal_3.isUsingTsSolutionSetup)(host)) {
69
- const hostPackageJsonPath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json');
70
- if (host.exists(hostPackageJsonPath)) {
71
- (0, devkit_1.updateJson)(host, hostPackageJsonPath, (json) => {
72
- json.name = options.projectName;
73
- return json;
74
- });
75
- }
76
- }
77
- const remotesWithPorts = [];
78
- if (schema.remotes) {
79
- let remotePort = options.port + 1;
80
- for (const remote of schema.remotes) {
81
- const remoteName = await (0, normalize_remote_1.normalizeRemoteName)(host, remote, options);
82
- remotesWithPorts.push({ name: remoteName, port: remotePort });
83
- const remoteTask = await (0, remote_1.default)(host, {
84
- name: remote,
85
- directory: (0, normalize_remote_1.normalizeRemoteDirectory)(remote, options),
86
- style: options.style,
87
- unitTestRunner: options.unitTestRunner,
88
- e2eTestRunner: options.e2eTestRunner,
89
- linter: options.linter,
90
- port: remotePort,
91
- ssr: options.ssr,
92
- skipFormat: true,
93
- typescriptConfiguration: options.typescriptConfiguration,
94
- js: options.js,
95
- dynamic: options.dynamic,
96
- host: options.projectName,
97
- skipPackageJson: options.skipPackageJson,
98
- bundler: options.bundler,
99
- });
100
- tasks.push(remoteTask);
101
- remotePort++;
102
- }
103
- }
104
- (0, add_module_federation_files_1.addModuleFederationFiles)(host, options, remotesWithPorts);
105
- (0, update_module_federation_project_1.updateModuleFederationProject)(host, options, true);
106
- (0, update_module_federation_e2e_project_1.updateModuleFederationE2eProject)(host, options);
107
- (0, update_module_federation_tsconfig_1.updateModuleFederationTsconfig)(host, options);
108
- // Add remotes as devDependencies in TS solution setup
109
- if ((0, internal_3.isUsingTsSolutionSetup)(host) && remotesWithPorts.length > 0) {
110
- addRemotesAsHostDependencies(host, options.projectName, remotesWithPorts);
111
- }
112
- if (options.ssr) {
113
- if (options.bundler !== 'rspack') {
114
- const setupSsrTask = await (0, setup_ssr_1.default)(host, {
115
- project: options.projectName,
116
- serverPort: options.port,
117
- skipFormat: true,
118
- });
119
- tasks.push(setupSsrTask);
120
- }
121
- const setupSsrForHostTask = await (0, setup_ssr_for_host_1.setupSsrForHost)(host, options, options.projectName, remotesWithPorts);
122
- tasks.push(setupSsrForHostTask);
123
- const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
124
- if (options.bundler !== 'rspack') {
125
- projectConfig.targets.server.options.webpackConfig = (0, devkit_1.joinPathFragments)(projectConfig.root, `webpack.server.config.${options.typescriptConfiguration ? 'ts' : 'js'}`);
126
- }
127
- (0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfig);
128
- }
129
- if (!(0, internal_2.isTypedLintingEnabled)(options)) {
130
- host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.lint.json'));
131
- }
132
- (0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host, options.bundler);
133
- const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, { '@module-federation/enhanced': versions_1.moduleFederationEnhancedVersion }, {
134
- '@nx/web': versions_1.nxVersion,
135
- '@nx/module-federation': versions_1.nxVersion,
136
- // The webpack path also generates a `serve-static` target running the
137
- // `module-federation-static-server` executor, which proxies via express.
138
- ...(options.bundler !== 'rspack'
139
- ? {
140
- express: versions_1.expressVersion,
141
- 'http-proxy-middleware': versions_1.httpProxyMiddlewareVersion,
142
- }
143
- : {}),
144
- }, undefined, true);
145
- tasks.push(installTask);
146
- // The TS config templates use extensionless relative imports and
147
- // `__dirname`, which Node's native type stripping cannot load.
148
- if (options.typescriptConfiguration) {
149
- tasks.push((0, internal_3.addSwcRegisterDependencies)(host));
150
- }
151
- if (!options.skipFormat) {
152
- await (0, devkit_1.formatFiles)(host);
153
- }
154
- return (0, devkit_1.runTasksInSerial)(...tasks);
155
- }
156
- function addRemotesAsHostDependencies(tree, hostName, remotes) {
157
- const hostConfig = (0, devkit_1.readProjectConfiguration)(tree, hostName);
158
- const hostPackageJsonPath = (0, devkit_1.joinPathFragments)(hostConfig.root, 'package.json');
159
- if (!tree.exists(hostPackageJsonPath)) {
160
- throw new Error(`Host package.json not found at ${hostPackageJsonPath}. ` +
161
- `TypeScript solution setup requires package.json for all projects.`);
162
- }
163
- const packageManager = (0, devkit_1.detectPackageManager)(tree.root);
164
- const versionSpec = packageManager === 'npm' ? '*' : 'workspace:*';
165
- (0, devkit_1.updateJson)(tree, hostPackageJsonPath, (json) => {
166
- json.devDependencies ??= {};
167
- for (const remote of remotes) {
168
- // Use simple remote name directly to match module-federation.config.ts
169
- json.devDependencies[remote.name] = versionSpec;
170
- }
171
- return json;
172
- });
173
- }
174
- exports.default = hostGenerator;