@nx/react 17.0.5 → 17.0.6

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 (154) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +4 -9
  3. package/generators.json +1 -1
  4. package/index.d.ts +0 -1
  5. package/index.js +1 -3
  6. package/migrations.json +0 -21
  7. package/package.json +7 -7
  8. package/plugins/component-testing/index.js +24 -52
  9. package/plugins/component-testing/webpack-fallback.js +1 -1
  10. package/plugins/storybook/index.js +2 -6
  11. package/plugins/storybook/merge-plugins.d.ts +1 -1
  12. package/plugins/webpack.d.ts +3 -1
  13. package/plugins/webpack.js +11 -3
  14. package/plugins/with-react.d.ts +4 -2
  15. package/plugins/with-react.js +58 -2
  16. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +0 -13
  17. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +58 -173
  18. package/src/executors/module-federation-dev-server/schema.json +1 -13
  19. package/src/generators/application/application.js +18 -41
  20. package/src/generators/application/files/base-vite/index.html__tmpl__ +1 -1
  21. package/src/generators/application/files/base-webpack/src/environments/environment.prod.ts__tmpl__ +3 -0
  22. package/src/generators/application/files/base-webpack/src/environments/environment.ts__tmpl__ +6 -0
  23. package/src/generators/application/files/base-webpack/src/index.html +2 -0
  24. package/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +5 -46
  25. package/src/generators/application/files/nx-welcome/src/app/nx-welcome.tsx +13 -54
  26. package/src/generators/application/lib/add-e2e.js +7 -25
  27. package/src/generators/application/lib/add-jest.js +2 -2
  28. package/src/generators/application/lib/add-project.d.ts +2 -2
  29. package/src/generators/application/lib/add-project.js +15 -12
  30. package/src/generators/application/lib/add-routing.d.ts +1 -1
  31. package/src/generators/application/lib/add-routing.js +8 -4
  32. package/src/generators/application/lib/create-application-files.js +1 -30
  33. package/src/generators/application/lib/install-common-dependencies.js +1 -15
  34. package/src/generators/application/lib/normalize-options.js +1 -35
  35. package/src/generators/application/lib/set-defaults.js +0 -1
  36. package/src/generators/application/lib/update-jest-config.js +8 -8
  37. package/src/generators/application/schema.d.ts +0 -5
  38. package/src/generators/application/schema.json +3 -7
  39. package/src/generators/component/files/__fileName__.tsx__tmpl__ +22 -39
  40. package/src/generators/component/lib/normalize-options.js +2 -4
  41. package/src/generators/component/schema.d.ts +4 -6
  42. package/src/generators/component/schema.json +7 -7
  43. package/src/generators/component-cypress-spec/schema.json +1 -1
  44. package/src/generators/component-story/schema.json +1 -1
  45. package/src/generators/component-test/schema.json +1 -1
  46. package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts +1 -2
  47. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +7 -18
  48. package/src/generators/cypress-component-configuration/lib/add-files.js +6 -1
  49. package/src/generators/cypress-component-configuration/schema.d.ts +0 -1
  50. package/src/generators/federate-module/federate-module.js +2 -2
  51. package/src/generators/federate-module/schema.d.ts +1 -1
  52. package/src/generators/federate-module/schema.json +3 -4
  53. package/src/generators/hook/files/__fileName__.ts__tmpl__ +15 -15
  54. package/src/generators/hook/schema.d.ts +4 -4
  55. package/src/generators/hook/schema.json +5 -5
  56. package/src/generators/host/files/module-federation/module-federation.config.js__tmpl__ +2 -17
  57. package/src/generators/host/files/module-federation/src/main.ts__tmpl__ +1 -0
  58. package/src/generators/host/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +2 -5
  59. package/src/generators/host/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +2 -5
  60. package/src/generators/host/files/module-federation-ts/module-federation.config.ts__tmpl__ +2 -17
  61. package/src/generators/host/files/module-federation-ts/src/main.ts__tmpl__ +1 -0
  62. package/src/generators/host/files/module-federation-ts/webpack.config.prod.ts__tmpl__ +1 -2
  63. package/src/generators/host/files/module-federation-ts/webpack.config.ts__tmpl__ +2 -2
  64. package/src/generators/host/host.js +1 -15
  65. package/src/generators/host/lib/add-module-federation-files.d.ts +1 -2
  66. package/src/generators/host/lib/add-module-federation-files.js +11 -24
  67. package/src/generators/host/lib/setup-ssr-for-host.js +0 -1
  68. package/src/generators/host/lib/update-module-federation-e2e-project.js +5 -7
  69. package/src/generators/host/schema.d.ts +2 -5
  70. package/src/generators/host/schema.json +6 -16
  71. package/src/generators/init/init.d.ts +1 -1
  72. package/src/generators/init/init.js +49 -10
  73. package/src/generators/init/schema.d.ts +6 -1
  74. package/src/generators/init/schema.json +22 -5
  75. package/src/generators/library/lib/add-linting.js +2 -2
  76. package/src/generators/library/lib/add-rollup-build-target.d.ts +1 -2
  77. package/src/generators/library/lib/add-rollup-build-target.js +8 -16
  78. package/src/generators/library/lib/install-common-dependencies.js +5 -13
  79. package/src/generators/library/lib/maybe-js.d.ts +2 -0
  80. package/src/generators/library/lib/normalize-options.js +5 -34
  81. package/src/generators/library/lib/update-app-routes.js +1 -1
  82. package/src/generators/library/library.js +6 -17
  83. package/src/generators/library/schema.d.ts +0 -1
  84. package/src/generators/library/schema.json +3 -3
  85. package/src/generators/redux/schema.d.ts +1 -1
  86. package/src/generators/redux/schema.json +2 -2
  87. package/src/generators/remote/files/module-federation/module-federation.config.js__tmpl__ +1 -4
  88. package/src/generators/remote/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +1 -1
  89. package/src/generators/remote/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +1 -1
  90. package/src/generators/remote/files/module-federation-ts/module-federation.config.ts__tmpl__ +1 -4
  91. package/src/generators/remote/lib/setup-ssr-for-remote.js +1 -5
  92. package/src/generators/remote/lib/setup-tspath-for-remote.js +1 -2
  93. package/src/generators/remote/lib/update-host-with-remote.js +1 -10
  94. package/src/generators/remote/remote.js +2 -22
  95. package/src/generators/remote/schema.d.ts +2 -3
  96. package/src/generators/remote/schema.json +6 -17
  97. package/src/generators/setup-ssr/schema.json +1 -1
  98. package/src/generators/setup-ssr/setup-ssr.js +7 -23
  99. package/src/generators/setup-tailwind/schema.json +1 -1
  100. package/src/generators/stories/schema.json +1 -1
  101. package/src/generators/stories/stories.js +5 -17
  102. package/src/generators/storybook-configuration/configuration.d.ts +0 -2
  103. package/src/generators/storybook-configuration/configuration.js +15 -37
  104. package/src/generators/storybook-configuration/schema.d.ts +1 -2
  105. package/src/generators/storybook-configuration/schema.json +7 -7
  106. package/src/module-federation/ast-utils.js +1 -1
  107. package/src/module-federation/utils.js +1 -8
  108. package/src/module-federation/with-module-federation-ssr.js +0 -3
  109. package/src/module-federation/with-module-federation.d.ts +3 -3
  110. package/src/module-federation/with-module-federation.js +4 -14
  111. package/src/rules/update-module-federation-project.d.ts +0 -2
  112. package/src/rules/update-module-federation-project.js +3 -12
  113. package/src/utils/assertion.js +0 -1
  114. package/src/utils/ct-utils.d.ts +1 -6
  115. package/src/utils/ct-utils.js +9 -39
  116. package/src/utils/get-in-source-vitest-tests-template.js +1 -1
  117. package/src/utils/versions.d.ts +1 -1
  118. package/src/utils/versions.js +1 -1
  119. package/typings/style.d.ts +0 -1
  120. package/mf/dynamic-federation.d.ts +0 -4
  121. package/mf/dynamic-federation.js +0 -75
  122. package/mf/index.d.ts +0 -1
  123. package/mf/index.js +0 -7
  124. package/plugins/nx-react-webpack-plugin/lib/apply-react-config.d.ts +0 -4
  125. package/plugins/nx-react-webpack-plugin/lib/apply-react-config.js +0 -86
  126. package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.d.ts +0 -8
  127. package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.js +0 -13
  128. package/src/generators/application/files/style-tailwind/src/app/__fileName__.tsx__tmpl__ +0 -33
  129. package/src/generators/application/files/style-tailwind/src/styles.css +0 -1
  130. package/src/generators/host/files/common/src/main.js__tmpl__ +0 -10
  131. package/src/generators/host/files/common/tsconfig.lint.json__tmpl__ +0 -19
  132. package/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ +0 -41
  133. package/src/generators/host/files/common-ts/src/main.ts__tmpl__ +0 -10
  134. package/src/generators/remote/files/module-federation-ssr-ts/tsconfig.lint.json__tmpl__ +0 -19
  135. package/src/generators/remote/files/module-federation-ts/tsconfig.lint.json__tmpl__ +0 -19
  136. package/src/generators/remote/lib/add-remote-to-dynamic-host.d.ts +0 -2
  137. package/src/generators/remote/lib/add-remote-to-dynamic-host.js +0 -11
  138. package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.d.ts +0 -2
  139. package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.js +0 -26
  140. package/src/migrations/update-18-1-1/fix-target-defaults-inputs.d.ts +0 -2
  141. package/src/migrations/update-18-1-1/fix-target-defaults-inputs.js +0 -53
  142. package/src/utils/add-mf-env-to-inputs.d.ts +0 -2
  143. package/src/utils/add-mf-env-to-inputs.js +0 -27
  144. package/src/utils/has-vite-plugin.d.ts +0 -2
  145. package/src/utils/has-vite-plugin.js +0 -11
  146. package/src/utils/has-webpack-plugin.d.ts +0 -2
  147. package/src/utils/has-webpack-plugin.js +0 -11
  148. package/src/utils/maybe-js.d.ts +0 -3
  149. /package/src/generators/host/files/common/src/app/{__fileName__.js__tmpl__ → __fileName__.tsx__tmpl__} +0 -0
  150. /package/src/{utils → generators/library/lib}/maybe-js.js +0 -0
  151. /package/src/generators/remote/files/{common/src/main.js__tmpl__ → module-federation/src/main.ts__tmpl__} +0 -0
  152. /package/src/generators/remote/files/{common/src/remote-entry.js__tmpl__ → module-federation/src/remote-entry.ts__tmpl__} +0 -0
  153. /package/src/generators/remote/files/{common-ts → module-federation-ts}/src/main.ts__tmpl__ +0 -0
  154. /package/src/generators/remote/files/{common-ts → module-federation-ts}/src/remote-entry.ts__tmpl__ +0 -0
@@ -1,18 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseStaticRemotesConfig = void 0;
4
3
  const devkit_1 = require("@nx/devkit");
5
4
  const dev_server_impl_1 = require("@nx/webpack/src/executors/dev-server/dev-server.impl");
6
5
  const file_server_impl_1 = require("@nx/web/src/executors/file-server/file-server.impl");
7
6
  const module_federation_1 = require("@nx/webpack/src/utils/module-federation");
8
7
  const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
9
8
  const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
10
- const cache_directory_1 = require("nx/src/utils/cache-directory");
11
- const node_child_process_1 = require("node:child_process");
12
- const node_path_1 = require("node:path");
13
- const node_fs_1 = require("node:fs");
14
- const fs_1 = require("fs");
15
- const path_1 = require("path");
9
+ const child_process_1 = require("child_process");
16
10
  function getBuildOptions(buildTarget, context) {
17
11
  const target = (0, devkit_1.parseTargetString)(buildTarget, context);
18
12
  const buildOptions = (0, devkit_1.readTargetOptions)(target, context);
@@ -20,133 +14,7 @@ function getBuildOptions(buildTarget, context) {
20
14
  ...buildOptions,
21
15
  };
22
16
  }
23
- function startStaticRemotesFileServer(staticRemotesConfig, context, options) {
24
- let shouldMoveToCommonLocation = false;
25
- let commonOutputDirectory;
26
- for (const app of staticRemotesConfig.remotes) {
27
- const remoteBasePath = staticRemotesConfig.config[app].basePath;
28
- if (!commonOutputDirectory) {
29
- commonOutputDirectory = remoteBasePath;
30
- }
31
- else if (commonOutputDirectory !== remoteBasePath) {
32
- shouldMoveToCommonLocation = true;
33
- break;
34
- }
35
- }
36
- if (shouldMoveToCommonLocation) {
37
- commonOutputDirectory = (0, node_path_1.join)(devkit_1.workspaceRoot, 'tmp/static-remotes');
38
- for (const app of staticRemotesConfig.remotes) {
39
- const remoteConfig = staticRemotesConfig.config[app];
40
- (0, node_fs_1.cpSync)(remoteConfig.outputPath, (0, node_path_1.join)(commonOutputDirectory, remoteConfig.urlSegment), {
41
- force: true,
42
- recursive: true,
43
- });
44
- }
45
- }
46
- const staticRemotesIter = (0, file_server_impl_1.default)({
47
- cors: true,
48
- watch: false,
49
- staticFilePath: commonOutputDirectory,
50
- parallel: false,
51
- spa: false,
52
- withDeps: false,
53
- host: options.host,
54
- port: options.staticRemotesPort,
55
- ssl: options.ssl,
56
- sslCert: options.sslCert,
57
- sslKey: options.sslKey,
58
- }, context);
59
- return staticRemotesIter;
60
- }
61
- async function startRemotes(remotes, context, options, target = 'serve') {
62
- const remoteIters = [];
63
- for (const app of remotes) {
64
- const remoteProjectServeTarget = context.projectGraph.nodes[app].data.targets[target];
65
- const isUsingModuleFederationDevServerExecutor = remoteProjectServeTarget.executor.includes('module-federation-dev-server');
66
- const overrides = target === 'serve'
67
- ? {
68
- watch: true,
69
- ...(options.host ? { host: options.host } : {}),
70
- ...(options.ssl ? { ssl: options.ssl } : {}),
71
- ...(options.sslCert ? { sslCert: options.sslCert } : {}),
72
- ...(options.sslKey ? { sslKey: options.sslKey } : {}),
73
- ...(isUsingModuleFederationDevServerExecutor
74
- ? { isInitialHost: false }
75
- : {}),
76
- }
77
- : {};
78
- remoteIters.push(await (0, devkit_1.runExecutor)({
79
- project: app,
80
- target,
81
- configuration: context.configurationName,
82
- }, overrides, context));
83
- }
84
- return remoteIters;
85
- }
86
- async function buildStaticRemotes(staticRemotesConfig, nxBin, context, options) {
87
- if (!staticRemotesConfig.remotes.length) {
88
- return;
89
- }
90
- devkit_1.logger.info(`NX Building ${staticRemotesConfig.remotes.length} static remotes...`);
91
- const mappedLocationOfRemotes = {};
92
- for (const app of staticRemotesConfig.remotes) {
93
- mappedLocationOfRemotes[app] = `http${options.ssl ? 's' : ''}://${options.host}:${options.staticRemotesPort}/${staticRemotesConfig.config[app].urlSegment}`;
94
- }
95
- process.env.NX_MF_DEV_SERVER_STATIC_REMOTES = JSON.stringify(mappedLocationOfRemotes);
96
- await new Promise((res) => {
97
- const staticProcess = (0, node_child_process_1.fork)(nxBin, [
98
- 'run-many',
99
- `--target=build`,
100
- `--projects=${staticRemotesConfig.remotes.join(',')}`,
101
- ...(context.configurationName
102
- ? [`--configuration=${context.configurationName}`]
103
- : []),
104
- ...(options.parallel ? [`--parallel=${options.parallel}`] : []),
105
- ], {
106
- cwd: context.root,
107
- stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
108
- });
109
- // File to debug build failures e.g. 2024-01-01T00_00_0_0Z-build.log'
110
- const remoteBuildLogFile = (0, node_path_1.join)(cache_directory_1.projectGraphCacheDirectory, `${new Date().toISOString().replace(/[:\.]/g, '_')}-build.log`);
111
- const stdoutStream = (0, node_fs_1.createWriteStream)(remoteBuildLogFile);
112
- staticProcess.stdout.on('data', (data) => {
113
- const ANSII_CODE_REGEX = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
114
- const stdoutString = data.toString().replace(ANSII_CODE_REGEX, '');
115
- stdoutStream.write(stdoutString);
116
- if (stdoutString.includes('Successfully ran target build')) {
117
- staticProcess.stdout.removeAllListeners('data');
118
- devkit_1.logger.info(`NX Built ${staticRemotesConfig.remotes.length} static remotes`);
119
- res();
120
- }
121
- });
122
- staticProcess.stderr.on('data', (data) => devkit_1.logger.info(data.toString()));
123
- staticProcess.on('exit', (code) => {
124
- stdoutStream.end();
125
- if (code !== 0) {
126
- throw new Error(`Remote failed to start. A complete log can be found in: ${remoteBuildLogFile}`);
127
- }
128
- });
129
- process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
130
- process.on('exit', () => staticProcess.kill('SIGTERM'));
131
- });
132
- }
133
- function parseStaticRemotesConfig(staticRemotes, context) {
134
- if (!staticRemotes?.length) {
135
- return { remotes: [], config: undefined };
136
- }
137
- const config = {};
138
- for (const app of staticRemotes) {
139
- const outputPath = context.projectGraph.nodes[app].data.targets['build'].options.outputPath;
140
- const basePath = (0, node_path_1.dirname)(outputPath);
141
- const urlSegment = (0, node_path_1.basename)(outputPath);
142
- config[app] = { basePath, outputPath, urlSegment };
143
- }
144
- return { remotes: staticRemotes, config };
145
- }
146
- exports.parseStaticRemotesConfig = parseStaticRemotesConfig;
147
17
  async function* moduleFederationDevServer(options, context) {
148
- const initialStaticRemotesPorts = options.staticRemotesPort;
149
- options.staticRemotesPort ??= options.port + 1;
150
18
  // Force Node to resolve to look for the nx binary that is inside node_modules
151
19
  const nxBin = require.resolve('nx/bin/nx');
152
20
  const currIter = options.static
@@ -160,17 +28,6 @@ async function* moduleFederationDevServer(options, context) {
160
28
  : (0, dev_server_impl_1.default)(options, context);
161
29
  const p = context.projectsConfigurations.projects[context.projectName];
162
30
  const buildOptions = getBuildOptions(options.buildTarget, context);
163
- let pathToManifestFile = (0, node_path_1.join)(context.root, p.sourceRoot, 'assets/module-federation.manifest.json');
164
- if (options.pathToManifestFile) {
165
- const userPathToManifestFile = (0, node_path_1.join)(context.root, options.pathToManifestFile);
166
- if (!(0, fs_1.existsSync)(userPathToManifestFile)) {
167
- throw new Error(`The provided Module Federation manifest file path does not exist. Please check the file exists at "${userPathToManifestFile}".`);
168
- }
169
- else if ((0, path_1.extname)(options.pathToManifestFile) !== '.json') {
170
- throw new Error(`The Module Federation manifest file must be a JSON. Please ensure the file at ${userPathToManifestFile} is a JSON.`);
171
- }
172
- pathToManifestFile = userPathToManifestFile;
173
- }
174
31
  if (!options.isInitialHost) {
175
32
  return yield* currIter;
176
33
  }
@@ -179,26 +36,57 @@ async function* moduleFederationDevServer(options, context) {
179
36
  projectName: context.projectName,
180
37
  projectGraph: context.projectGraph,
181
38
  root: context.root,
182
- }, pathToManifestFile);
183
- if (remotes.devRemotes.length > 0 && !initialStaticRemotesPorts) {
184
- options.staticRemotesPort = options.devRemotes.reduce((portToUse, r) => {
185
- const remotePort = context.projectGraph.nodes[r].data.targets['serve'].options.port;
186
- if (remotePort >= portToUse) {
187
- return remotePort + 1;
39
+ });
40
+ let isCollectingStaticRemoteOutput = true;
41
+ const devRemoteIters = [];
42
+ for (const app of remotes.devRemotes) {
43
+ const remoteProjectServeTarget = context.projectGraph.nodes[app].data.targets['serve'];
44
+ const isUsingModuleFederationDevServerExecutor = remoteProjectServeTarget.executor.includes('module-federation-dev-server');
45
+ devRemoteIters.push(await (0, devkit_1.runExecutor)({
46
+ project: app,
47
+ target: 'serve',
48
+ configuration: context.configurationName,
49
+ }, {
50
+ watch: true,
51
+ ...(isUsingModuleFederationDevServerExecutor
52
+ ? { isInitialHost: false }
53
+ : {}),
54
+ }, context));
55
+ }
56
+ for (const app of remotes.staticRemotes) {
57
+ const remoteProjectServeTarget = context.projectGraph.nodes[app].data.targets['serve-static'];
58
+ const isUsingModuleFederationDevServerExecutor = remoteProjectServeTarget.executor.includes('module-federation-dev-server');
59
+ let outWithErr = [];
60
+ const staticProcess = (0, child_process_1.fork)(nxBin, [
61
+ 'run',
62
+ `${app}:serve-static${context.configurationName ? `:${context.configurationName}` : ''}`,
63
+ ...(isUsingModuleFederationDevServerExecutor
64
+ ? [`--isInitialHost=false`]
65
+ : []),
66
+ ], {
67
+ cwd: context.root,
68
+ stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
69
+ });
70
+ staticProcess.stdout.on('data', (data) => {
71
+ if (isCollectingStaticRemoteOutput) {
72
+ outWithErr.push(data.toString());
188
73
  }
189
74
  else {
190
- return portToUse;
75
+ outWithErr = null;
76
+ staticProcess.stdout.removeAllListeners('data');
77
+ }
78
+ });
79
+ staticProcess.stderr.on('data', (data) => devkit_1.logger.info(data.toString()));
80
+ staticProcess.on('exit', (code) => {
81
+ if (code !== 0) {
82
+ devkit_1.logger.info(outWithErr.join(''));
83
+ throw new Error(`Remote failed to start. See above for errors.`);
191
84
  }
192
- }, options.staticRemotesPort);
85
+ });
86
+ process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
87
+ process.on('exit', () => staticProcess.kill('SIGTERM'));
193
88
  }
194
- const staticRemotesConfig = parseStaticRemotesConfig(remotes.staticRemotes, context);
195
- await buildStaticRemotes(staticRemotesConfig, nxBin, context, options);
196
- const devRemoteIters = await startRemotes(remotes.devRemotes, context, options, 'serve');
197
- const dynamicRemotesIters = await startRemotes(remotes.dynamicRemotes, context, options, 'serve-static');
198
- const staticRemotesIter = remotes.staticRemotes.length > 0
199
- ? startStaticRemotesFileServer(staticRemotesConfig, context, options)
200
- : undefined;
201
- return yield* (0, async_iterable_1.combineAsyncIterables)(currIter, ...devRemoteIters, ...dynamicRemotesIters, ...(staticRemotesIter ? [staticRemotesIter] : []), (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
89
+ return yield* (0, async_iterable_1.combineAsyncIterables)(currIter, ...devRemoteIters, (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
202
90
  if (!options.isInitialHost) {
203
91
  done();
204
92
  return;
@@ -208,23 +96,20 @@ async function* moduleFederationDevServer(options, context) {
208
96
  return;
209
97
  }
210
98
  try {
211
- const host = options.host ?? 'localhost';
212
- const baseUrl = `http${options.ssl ? 's' : ''}://${host}:${options.port}`;
213
- const portsToWaitFor = staticRemotesIter
214
- ? [options.staticRemotesPort, ...remotes.remotePorts]
215
- : [...remotes.remotePorts];
216
- await Promise.all(portsToWaitFor.map((port) => (0, wait_for_port_open_1.waitForPortOpen)(port, {
99
+ await Promise.all(remotes.remotePorts.map((port) =>
100
+ // Allow 20 minutes for each remote to start, which is plenty of time but we can tweak it later if needed.
101
+ // Most remotes should start in under 1 minute.
102
+ (0, wait_for_port_open_1.waitForPortOpen)(port, {
217
103
  retries: 480,
218
104
  retryDelay: 2500,
219
- host: host,
105
+ host: 'localhost',
220
106
  })));
221
- devkit_1.logger.info(`NX All remotes started, server ready at ${baseUrl}`);
222
- next({ success: true, baseUrl: baseUrl });
107
+ isCollectingStaticRemoteOutput = false;
108
+ devkit_1.logger.info(`NX All remotes started, server ready at http://localhost:${options.port}`);
109
+ next({ success: true, baseUrl: `http://localhost:${options.port}` });
223
110
  }
224
- catch (err) {
225
- throw new Error(`Failed to start remotes. Check above for any errors.`, {
226
- cause: err,
227
- });
111
+ catch {
112
+ throw new Error(`Timed out waiting for remote to start. Check above for any errors.`);
228
113
  }
229
114
  finally {
230
115
  done();
@@ -19,7 +19,7 @@
19
19
  "items": {
20
20
  "type": "string"
21
21
  },
22
- "description": "List of remote applications to not automatically serve, either statically or in development mode. This will not remove the remotes from the `module-federation.config` file, and therefore the application may still try to fetch these remotes.\nThis option is useful for when the `host` application is using a `remote` that does not live in the same workspace as the `host`.",
22
+ "description": "List of remote applications to not automatically serve, either statically or in development mode.",
23
23
  "x-priority": "important"
24
24
  },
25
25
  "buildTarget": {
@@ -101,18 +101,6 @@
101
101
  "description": "Whether the host that is running this executor is the first in the project tree to do so.",
102
102
  "default": true,
103
103
  "x-priority": "internal"
104
- },
105
- "parallel": {
106
- "type": "number",
107
- "description": "Max number of parallel processes for building static remotes"
108
- },
109
- "staticRemotesPort": {
110
- "type": "number",
111
- "description": "The port at which to serve the file-server for the static remotes."
112
- },
113
- "pathToManifestFile": {
114
- "type": "string",
115
- "description": "Path to a Module Federation manifest file (e.g. `my/path/to/module-federation.manifest.json`) containing the dynamic remote applications relative to the workspace root."
116
104
  }
117
105
  }
118
106
  }
@@ -13,8 +13,8 @@ const add_styled_dependencies_1 = require("../../rules/add-styled-dependencies")
13
13
  const devkit_1 = require("@nx/devkit");
14
14
  const init_1 = require("../init/init");
15
15
  const eslint_1 = require("@nx/eslint");
16
+ const lint_project_1 = require("@nx/eslint/src/generators/lint-project/lint-project");
16
17
  const versions_1 = require("../../utils/versions");
17
- const maybe_js_1 = require("../../utils/maybe-js");
18
18
  const install_common_dependencies_1 = require("./lib/install-common-dependencies");
19
19
  const create_ts_config_1 = require("../../utils/create-ts-config");
20
20
  const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
@@ -22,9 +22,6 @@ const chalk = require("chalk");
22
22
  const show_possible_warnings_1 = require("./lib/show-possible-warnings");
23
23
  const add_e2e_1 = require("./lib/add-e2e");
24
24
  const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
25
- const js_1 = require("@nx/js");
26
- const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
27
- const setup_tailwind_1 = require("../setup-tailwind/setup-tailwind");
28
25
  async function addLinting(host, options) {
29
26
  const tasks = [];
30
27
  if (options.linter === eslint_1.Linter.EsLint) {
@@ -35,10 +32,12 @@ async function addLinting(host, options) {
35
32
  (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
36
33
  ],
37
34
  unitTestRunner: options.unitTestRunner,
35
+ eslintFilePatterns: [
36
+ (0, lint_project_1.mapLintPattern)(options.appProjectRoot, '{ts,tsx,js,jsx}', options.rootProject),
37
+ ],
38
38
  skipFormat: true,
39
39
  rootProject: options.rootProject,
40
40
  skipPackageJson: options.skipPackageJson,
41
- addPlugin: options.addPlugin,
42
41
  });
43
42
  tasks.push(lintTask);
44
43
  if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
@@ -54,7 +53,6 @@ async function addLinting(host, options) {
54
53
  }
55
54
  async function applicationGenerator(host, schema) {
56
55
  return await applicationGeneratorInternal(host, {
57
- addPlugin: false,
58
56
  projectNameAndRootFormat: 'derived',
59
57
  ...schema,
60
58
  });
@@ -64,41 +62,17 @@ async function applicationGeneratorInternal(host, schema) {
64
62
  const tasks = [];
65
63
  const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
66
64
  (0, show_possible_warnings_1.showPossibleWarnings)(host, options);
67
- const jsInitTask = await (0, js_1.initGenerator)(host, {
68
- ...schema,
69
- tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
70
- skipFormat: true,
71
- });
72
- tasks.push(jsInitTask);
73
65
  const initTask = await (0, init_1.default)(host, {
74
66
  ...options,
75
67
  skipFormat: true,
68
+ skipHelperLibs: options.bundler === 'vite',
76
69
  });
77
70
  tasks.push(initTask);
78
- if (options.bundler === 'webpack') {
79
- const { webpackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_1.nxVersion);
80
- const webpackInitTask = await webpackInitGenerator(host, {
81
- skipPackageJson: options.skipPackageJson,
82
- skipFormat: true,
83
- addPlugin: options.addPlugin,
84
- });
85
- tasks.push(webpackInitTask);
86
- if (!options.skipPackageJson) {
87
- const { ensureDependencies } = await Promise.resolve().then(() => require('@nx/webpack/src/utils/ensure-dependencies'));
88
- tasks.push(ensureDependencies(host, { uiFramework: 'react' }));
89
- }
90
- }
91
71
  if (!options.rootProject) {
92
72
  (0, create_ts_config_1.extractTsConfigBase)(host);
93
73
  }
94
74
  (0, create_application_files_1.createApplicationFiles)(host, options);
95
75
  (0, add_project_1.addProject)(host, options);
96
- if (options.style === 'tailwind') {
97
- const twTask = await (0, setup_tailwind_1.setupTailwindGenerator)(host, {
98
- project: options.projectName,
99
- });
100
- tasks.push(twTask);
101
- }
102
76
  if (options.bundler === 'vite') {
103
77
  const { createOrEditViteConfig, viteConfigurationGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
104
78
  // We recommend users use `import.meta.env.MODE` and other variables in their code to differentiate between production and development.
@@ -114,7 +88,6 @@ async function applicationGeneratorInternal(host, schema) {
114
88
  inSourceTests: options.inSourceTests,
115
89
  compiler: options.compiler,
116
90
  skipFormat: true,
117
- addPlugin: options.addPlugin,
118
91
  });
119
92
  tasks.push(viteTask);
120
93
  createOrEditViteConfig(host, {
@@ -135,15 +108,23 @@ async function applicationGeneratorInternal(host, schema) {
135
108
  plugins: ['react()'],
136
109
  }, false);
137
110
  }
111
+ else if (options.bundler === 'webpack') {
112
+ const { webpackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_1.nxVersion);
113
+ const webpackInitTask = await webpackInitGenerator(host, {
114
+ uiFramework: 'react',
115
+ skipFormat: true,
116
+ });
117
+ tasks.push(webpackInitTask);
118
+ }
138
119
  else if (options.bundler === 'rspack') {
139
120
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxRspackVersion);
140
121
  const rspackTask = await configurationGenerator(host, {
141
122
  project: options.projectName,
142
- main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, `src/main.tsx`)),
123
+ main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, add_project_1.maybeJs)(options, `src/main.tsx`)),
143
124
  tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
144
125
  target: 'web',
145
126
  newProject: true,
146
- framework: 'react',
127
+ uiFramework: 'react',
147
128
  });
148
129
  tasks.push(rspackTask);
149
130
  }
@@ -151,11 +132,10 @@ async function applicationGeneratorInternal(host, schema) {
151
132
  const { createOrEditViteConfig, vitestGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
152
133
  const vitestTask = await vitestGenerator(host, {
153
134
  uiFramework: 'react',
154
- coverageProvider: 'v8',
135
+ coverageProvider: 'c8',
155
136
  project: options.projectName,
156
137
  inSourceTests: options.inSourceTests,
157
138
  skipFormat: true,
158
- addPlugin: options.addPlugin,
159
139
  });
160
140
  tasks.push(vitestTask);
161
141
  createOrEditViteConfig(host, {
@@ -201,8 +181,8 @@ async function applicationGeneratorInternal(host, schema) {
201
181
  devkit_1.logger.warn(`${chalk.bold('styled-jsx')} is not supported by ${chalk.bold('Rspack')}. We've added ${chalk.bold('babel-loader')} to your project, but using babel will slow down your build.`);
202
182
  tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, {}, { 'babel-loader': versions_1.babelLoaderVersion }));
203
183
  host.write((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'rspack.config.js'), (0, devkit_1.stripIndents) `
204
- const { composePlugins, withNx, withReact } = require('@nx/rspack');
205
- module.exports = composePlugins(withNx(), withReact(), (config) => {
184
+ const { composePlugins, withNx, withWeb } = require('@nx/rspack');
185
+ module.exports = composePlugins(withNx(), withWeb(), (config) => {
206
186
  config.module.rules.push({
207
187
  test: /\\.[jt]sx$/i,
208
188
  use: [
@@ -222,9 +202,6 @@ async function applicationGeneratorInternal(host, schema) {
222
202
  if (!options.skipFormat) {
223
203
  await (0, devkit_1.formatFiles)(host);
224
204
  }
225
- tasks.push(() => {
226
- (0, log_show_project_command_1.logShowProjectCommand)(options.projectName);
227
- });
228
205
  return (0, devkit_1.runTasksInSerial)(...tasks);
229
206
  }
230
207
  exports.applicationGeneratorInternal = applicationGeneratorInternal;
@@ -7,7 +7,7 @@
7
7
 
8
8
  <meta name="viewport" content="width=device-width, initial-scale=1" />
9
9
  <link rel="icon" type="image/x-icon" href="/favicon.ico" />
10
- <% if (!styledModule && style !== 'none') { %><link rel="stylesheet" href="/src/styles.<%= style === 'tailwind' ? 'css' : style %>" /><% } %>
10
+ <% if (!styledModule && style !== 'none') { %><link rel="stylesheet" href="/src/styles.<%= style %>" /><% } %>
11
11
  </head>
12
12
  <body>
13
13
  <div id="root"></div>
@@ -0,0 +1,3 @@
1
+ export const environment = {
2
+ production: true
3
+ };
@@ -0,0 +1,6 @@
1
+ // This file can be replaced during build by using the `fileReplacements` array.
2
+ // When building for production, this file is replaced with `environment.prod.ts`.
3
+
4
+ export const environment = {
5
+ production: false
6
+ };
@@ -3,6 +3,8 @@
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <title><%= className %></title>
6
+ <base href="/" />
7
+
6
8
  <meta name="viewport" content="width=device-width, initial-scale=1" />
7
9
  <link rel="icon" type="image/x-icon" href="favicon.ico" />
8
10
  </head>
@@ -1,50 +1,9 @@
1
- <% if (webpackPluginOptions) { %>
2
- const { NxWebpackPlugin } = require('@nx/webpack');
3
- const { NxReactWebpackPlugin } = require('@nx/react');
4
- const { join } = require('path');
5
-
6
- module.exports = {
7
- output: {
8
- path: join(__dirname, '<%= offsetFromRoot %><%= webpackPluginOptions.outputPath %>'),
9
- },
10
- devServer: {
11
- port: 4200
12
- },
13
- plugins: [
14
- new NxWebpackPlugin({
15
- tsConfig: '<%= webpackPluginOptions.tsConfig %>',
16
- compiler: '<%= webpackPluginOptions.compiler %>',
17
- main: '<%= webpackPluginOptions.main %>',
18
- index: '<%= webpackPluginOptions.index %>',
19
- baseHref: '<%= webpackPluginOptions.baseHref %>',
20
- assets: <%- JSON.stringify(webpackPluginOptions.assets) %>,
21
- styles: <%- JSON.stringify(webpackPluginOptions.styles) %>,
22
- outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none',
23
- optimization: process.env['NODE_ENV'] === 'production',
24
- }),
25
- new NxReactWebpackPlugin({
26
- // Uncomment this line if you don't want to use SVGR
27
- // See: https://react-svgr.com/
28
- // svgr: false
29
- }),
30
- ],
31
- };
32
- <% } else { %>
33
1
  const { composePlugins, withNx } = require('@nx/webpack');
34
2
  const { withReact } = require('@nx/react');
35
3
 
36
4
  // Nx plugins for webpack.
37
- module.exports = composePlugins(
38
- withNx(),
39
- withReact({
40
- // Uncomment this line if you don't want to use SVGR
41
- // See: https://react-svgr.com/
42
- // svgr: false
43
- }),
44
- (config) => {
45
- // Update the webpack config as needed here.
46
- // e.g. `config.plugins.push(new MyPlugin())`
47
- return config;
48
- }
49
- );
50
- <% } %>
5
+ module.exports = composePlugins(withNx(), withReact(), (config) => {
6
+ // Update the webpack config as needed here.
7
+ // e.g. `config.plugins.push(new MyPlugin())`
8
+ return config;
9
+ });