@nx/react 23.1.0 → 23.1.2

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 (51) hide show
  1. package/dist/internal.d.ts +1 -0
  2. package/dist/internal.js +3 -1
  3. package/dist/module-federation.d.ts +1 -2
  4. package/dist/module-federation.js +2 -3
  5. package/dist/plugins/component-testing/webpack-fallback.js +5 -0
  6. package/dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +11 -7
  7. package/dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +10 -6
  8. package/dist/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts +2 -2
  9. package/dist/src/executors/module-federation-static-server/module-federation-static-server.impl.js +14 -9
  10. package/dist/src/generators/application/application.js +7 -8
  11. package/dist/src/generators/application/files/react-router-ssr/common/app/entry.server.tsx__tmpl__ +1 -1
  12. package/dist/src/generators/application/files/react-router-ssr/common/tests/routes/_index.spec.tsx__tmpl__ +2 -2
  13. package/dist/src/generators/application/lib/add-e2e.js +3 -1
  14. package/dist/src/generators/application/lib/add-linting.js +3 -3
  15. package/dist/src/generators/application/lib/create-application-files.d.ts +1 -0
  16. package/dist/src/generators/application/lib/create-application-files.js +3 -3
  17. package/dist/src/generators/application/lib/find-free-port.d.ts +1 -1
  18. package/dist/src/generators/application/schema.d.ts +4 -0
  19. package/dist/src/generators/application/schema.json +8 -2
  20. package/dist/src/generators/cypress-component-configuration/lib/add-files.js +3 -3
  21. package/dist/src/generators/host/host.js +13 -4
  22. package/dist/src/generators/host/lib/setup-ssr-for-host.js +7 -8
  23. package/dist/src/generators/host/schema.d.ts +4 -0
  24. package/dist/src/generators/host/schema.json +8 -2
  25. package/dist/src/generators/library/lib/add-linting.d.ts +1 -2
  26. package/dist/src/generators/library/lib/add-linting.js +2 -3
  27. package/dist/src/generators/library/lib/add-rollup-build-target.d.ts +1 -2
  28. package/dist/src/generators/library/lib/determine-entry-fields.d.ts +1 -1
  29. package/dist/src/generators/library/lib/update-app-routes.js +1 -2
  30. package/dist/src/generators/library/schema.d.ts +4 -0
  31. package/dist/src/generators/library/schema.json +8 -2
  32. package/dist/src/generators/remote/lib/setup-ssr-for-remote.js +8 -9
  33. package/dist/src/generators/remote/lib/setup-tspath-for-remote.js +3 -2
  34. package/dist/src/generators/remote/remote.js +15 -6
  35. package/dist/src/generators/remote/schema.d.ts +4 -0
  36. package/dist/src/generators/remote/schema.json +8 -2
  37. package/dist/src/migrations/update-23-2-0/add-optional-module-federation-packages.d.ts +2 -0
  38. package/dist/src/migrations/update-23-2-0/add-optional-module-federation-packages.js +61 -0
  39. package/dist/src/migrations/update-23-2-0/add-optional-module-federation-packages.md +37 -0
  40. package/dist/src/migrations/update-23-2-0/add-svgr-webpack-if-used.d.ts +2 -0
  41. package/dist/src/migrations/update-23-2-0/add-svgr-webpack-if-used.js +55 -0
  42. package/dist/src/migrations/update-23-2-0/add-svgr-webpack-if-used.md +28 -0
  43. package/dist/src/plugins/router-plugin.js +2 -4
  44. package/dist/src/utils/assert-package.d.ts +1 -0
  45. package/dist/src/utils/assert-package.js +17 -0
  46. package/dist/src/utils/create-ts-config.d.ts +1 -1
  47. package/dist/src/utils/create-ts-config.js +5 -5
  48. package/dist/src/utils/versions.d.ts +2 -0
  49. package/dist/src/utils/versions.js +3 -1
  50. package/migrations.json +12 -0
  51. package/package.json +32 -20
@@ -1,5 +1,6 @@
1
1
  export { addE2e } from './src/generators/application/lib/add-e2e';
2
2
  export { addRollupBuildTarget } from './src/generators/library/lib/add-rollup-build-target';
3
+ export { assertPackageIsInstalled } from './src/utils/assert-package';
3
4
  export { isComponent } from './src/utils/ct-utils';
4
5
  export { suppressReactComposeHelperWarnings } from './src/utils/deprecation';
5
6
  export { hasWebpackPlugin } from './src/utils/has-webpack-plugin';
package/dist/internal.js CHANGED
@@ -5,11 +5,13 @@
5
5
  // internal consumers and may change without semver protection. Mirrors
6
6
  // `@nx/devkit/internal`.
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.babelPresetReactVersion = exports.babelCoreVersion = exports.testingLibraryReactVersion = exports.testingLibraryDomVersion = exports.isReact18 = exports.getReactDependenciesVersionsToInstall = exports.hasWebpackPlugin = exports.suppressReactComposeHelperWarnings = exports.isComponent = exports.addRollupBuildTarget = exports.addE2e = void 0;
8
+ exports.babelPresetReactVersion = exports.babelCoreVersion = exports.testingLibraryReactVersion = exports.testingLibraryDomVersion = exports.isReact18 = exports.getReactDependenciesVersionsToInstall = exports.hasWebpackPlugin = exports.suppressReactComposeHelperWarnings = exports.isComponent = exports.assertPackageIsInstalled = exports.addRollupBuildTarget = exports.addE2e = void 0;
9
9
  var add_e2e_1 = require("./src/generators/application/lib/add-e2e");
10
10
  Object.defineProperty(exports, "addE2e", { enumerable: true, get: function () { return add_e2e_1.addE2e; } });
11
11
  var add_rollup_build_target_1 = require("./src/generators/library/lib/add-rollup-build-target");
12
12
  Object.defineProperty(exports, "addRollupBuildTarget", { enumerable: true, get: function () { return add_rollup_build_target_1.addRollupBuildTarget; } });
13
+ var assert_package_1 = require("./src/utils/assert-package");
14
+ Object.defineProperty(exports, "assertPackageIsInstalled", { enumerable: true, get: function () { return assert_package_1.assertPackageIsInstalled; } });
13
15
  var ct_utils_1 = require("./src/utils/ct-utils");
14
16
  Object.defineProperty(exports, "isComponent", { enumerable: true, get: function () { return ct_utils_1.isComponent; } });
15
17
  var deprecation_1 = require("./src/utils/deprecation");
@@ -1,5 +1,4 @@
1
- import { withModuleFederation } from '@nx/module-federation/webpack';
2
- import { withModuleFederationForSSR } from '@nx/module-federation/webpack';
1
+ import { withModuleFederation, withModuleFederationForSSR } from '@nx/module-federation/webpack';
3
2
  /**
4
3
  * @deprecated Use `@nx/module-federation/webpack` instead. This will be removed in Nx v22.
5
4
  */
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withModuleFederationForSSR = exports.withModuleFederation = void 0;
4
4
  const webpack_1 = require("@nx/module-federation/webpack");
5
5
  Object.defineProperty(exports, "withModuleFederation", { enumerable: true, get: function () { return webpack_1.withModuleFederation; } });
6
- const webpack_2 = require("@nx/module-federation/webpack");
7
- Object.defineProperty(exports, "withModuleFederationForSSR", { enumerable: true, get: function () { return webpack_2.withModuleFederationForSSR; } });
6
+ Object.defineProperty(exports, "withModuleFederationForSSR", { enumerable: true, get: function () { return webpack_1.withModuleFederationForSSR; } });
8
7
  // Support for older generated code: `const withModuleFederation = require('@nx/react/module-federation')`
9
8
  /**
10
9
  * @deprecated Use `@nx/module-federation/webpack` instead. This will be removed in Nx v22.
@@ -18,4 +17,4 @@ module.exports.withModuleFederation = webpack_1.withModuleFederation;
18
17
  /**
19
18
  * @deprecated Use `@nx/module-federation/webpack` instead. This will be removed in Nx v22.
20
19
  */
21
- module.exports.withModuleFederationForSSR = webpack_2.withModuleFederationForSSR;
20
+ module.exports.withModuleFederationForSSR = webpack_1.withModuleFederationForSSR;
@@ -78,6 +78,11 @@ const loaderModulesOptions = {
78
78
  modules: {
79
79
  mode: 'local',
80
80
  getLocalIdent: webpack_1.getCSSModuleLocalIdent,
81
+ // css-loader 7 defaults namedExport to true, and to camel-case-only
82
+ // locals when it is off. Generated components import the default
83
+ // export and reference class names as authored, so pin both.
84
+ namedExport: false,
85
+ exportLocalsConvention: 'asIs',
81
86
  },
82
87
  importLoaders: 1,
83
88
  };
@@ -4,18 +4,22 @@ exports.default = moduleFederationDevServer;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const internal_1 = require("@nx/devkit/internal");
6
6
  const internal_2 = require("@nx/js/internal");
7
- const internal_3 = require("@nx/module-federation/internal");
8
- const internal_4 = require("@nx/web/internal");
9
- const webpack_1 = require("@nx/webpack");
7
+ const internal_3 = require("@nx/web/internal");
10
8
  const fs_1 = require("fs");
11
9
  const path_1 = require("path");
12
10
  const lib_1 = require("./lib");
11
+ const assert_package_1 = require("../../utils/assert-package");
13
12
  const module_federation_deprecation_1 = require("../../utils/module-federation-deprecation");
13
+ const executorName = '@nx/react:module-federation-dev-server';
14
14
  async function* moduleFederationDevServer(schema, context) {
15
+ (0, assert_package_1.assertPackageIsInstalled)('@nx/module-federation', executorName);
16
+ (0, assert_package_1.assertPackageIsInstalled)('@nx/webpack', executorName);
17
+ const { startRemoteIterators } = await import('@nx/module-federation/internal');
18
+ const { devServerExecutor } = await import('@nx/webpack');
15
19
  (0, module_federation_deprecation_1.warnReactMfDevServerExecutorDeprecation)();
16
20
  const options = (0, lib_1.normalizeOptions)(schema);
17
21
  const currIter = options.static
18
- ? (0, internal_4.fileServerExecutor)({
22
+ ? (0, internal_3.fileServerExecutor)({
19
23
  ...options,
20
24
  parallel: false,
21
25
  withDeps: false,
@@ -24,7 +28,7 @@ async function* moduleFederationDevServer(schema, context) {
24
28
  cacheSeconds: -1,
25
29
  }, context)
26
30
  : // TODO(JamesHenry): remove type assertion once the nx repo is updated to use https://github.com/nrwl/nx/pull/33095
27
- (0, webpack_1.devServerExecutor)(options, context);
31
+ devServerExecutor(options, context);
28
32
  const p = context.projectsConfigurations.projects[context.projectName];
29
33
  let pathToManifestFile = (0, path_1.join)(context.root, (0, internal_2.getProjectSourceRoot)(p), 'assets/module-federation.manifest.json');
30
34
  if (options.pathToManifestFile) {
@@ -40,7 +44,7 @@ async function* moduleFederationDevServer(schema, context) {
40
44
  if (!options.isInitialHost) {
41
45
  return yield* currIter;
42
46
  }
43
- const { staticRemotesIter, devRemoteIters, remotes } = await (0, internal_3.startRemoteIterators)(options, context, lib_1.startRemotes, pathToManifestFile, 'react');
47
+ const { staticRemotesIter, devRemoteIters, remotes } = await startRemoteIterators(options, context, lib_1.startRemotes, pathToManifestFile, 'react');
44
48
  return yield* (0, internal_1.combineAsyncIterables)(currIter, ...devRemoteIters, ...(staticRemotesIter ? [staticRemotesIter] : []), (0, internal_1.createAsyncIterable)(async ({ next, done }) => {
45
49
  if (!options.isInitialHost) {
46
50
  done();
@@ -56,7 +60,7 @@ async function* moduleFederationDevServer(schema, context) {
56
60
  const portsToWaitFor = staticRemotesIter && options.staticRemotesPort
57
61
  ? [options.staticRemotesPort, ...remotes.remotePorts]
58
62
  : [...remotes.remotePorts];
59
- await Promise.all(portsToWaitFor.map((port) => (0, internal_4.waitForPortOpen)(port, {
63
+ await Promise.all(portsToWaitFor.map((port) => (0, internal_3.waitForPortOpen)(port, {
60
64
  retries: 480,
61
65
  retryDelay: 2500,
62
66
  host: host,
@@ -4,18 +4,22 @@ exports.default = moduleFederationSsrDevServer;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const internal_1 = require("@nx/devkit/internal");
6
6
  const internal_2 = require("@nx/js/internal");
7
- const internal_3 = require("@nx/module-federation/internal");
8
- const internal_4 = require("@nx/web/internal");
9
- const internal_5 = require("@nx/webpack/internal");
7
+ const internal_3 = require("@nx/web/internal");
10
8
  const fs_1 = require("fs");
11
9
  const path_1 = require("path");
12
10
  const lib_1 = require("./lib");
11
+ const assert_package_1 = require("../../utils/assert-package");
13
12
  const module_federation_deprecation_1 = require("../../utils/module-federation-deprecation");
13
+ const executorName = '@nx/react:module-federation-ssr-dev-server';
14
14
  async function* moduleFederationSsrDevServer(ssrDevServerOptions, context) {
15
+ (0, assert_package_1.assertPackageIsInstalled)('@nx/module-federation', executorName);
16
+ (0, assert_package_1.assertPackageIsInstalled)('@nx/webpack', executorName);
17
+ const { startRemoteIterators } = await import('@nx/module-federation/internal');
18
+ const { ssrDevServerExecutor } = await import('@nx/webpack/internal');
15
19
  (0, module_federation_deprecation_1.warnReactMfSsrDevServerExecutorDeprecation)();
16
20
  const options = (0, lib_1.normalizeOptions)(ssrDevServerOptions);
17
21
  // TODO(JamesHenry): remove type assertion once the nx repo is updated to use https://github.com/nrwl/nx/pull/33095
18
- let iter = (0, internal_5.ssrDevServerExecutor)(options, context);
22
+ let iter = ssrDevServerExecutor(options, context);
19
23
  const projectConfig = context.projectsConfigurations.projects[context.projectName];
20
24
  let pathToManifestFile = (0, path_1.join)(context.root, (0, internal_2.getProjectSourceRoot)(projectConfig), 'assets/module-federation.manifest.json');
21
25
  if (options.pathToManifestFile) {
@@ -31,7 +35,7 @@ async function* moduleFederationSsrDevServer(ssrDevServerOptions, context) {
31
35
  if (!options.isInitialHost) {
32
36
  return yield* iter;
33
37
  }
34
- const { staticRemotesIter, devRemoteIters, remotes } = await (0, internal_3.startRemoteIterators)(options, context, lib_1.startRemotes, pathToManifestFile, 'react', true);
38
+ const { staticRemotesIter, devRemoteIters, remotes } = await startRemoteIterators(options, context, lib_1.startRemotes, pathToManifestFile, 'react', true);
35
39
  const combined = (0, internal_1.combineAsyncIterables)(staticRemotesIter, ...devRemoteIters);
36
40
  let refs = 1 + (devRemoteIters?.length ?? 0);
37
41
  for await (const result of combined) {
@@ -59,7 +63,7 @@ async function* moduleFederationSsrDevServer(ssrDevServerOptions, context) {
59
63
  const portsToWaitFor = staticRemotesIter && options.staticRemotesPort
60
64
  ? [options.staticRemotesPort, ...remotes.remotePorts]
61
65
  : [...remotes.remotePorts];
62
- await Promise.all(portsToWaitFor.map((port) => (0, internal_4.waitForPortOpen)(port, {
66
+ await Promise.all(portsToWaitFor.map((port) => (0, internal_3.waitForPortOpen)(port, {
63
67
  retries: 480,
64
68
  retryDelay: 2500,
65
69
  host,
@@ -1,5 +1,5 @@
1
- import { StaticRemotesConfig } from '@nx/module-federation/internal';
2
- import { ExecutorContext } from 'nx/src/config/misc-interfaces';
1
+ import { ExecutorContext } from '@nx/devkit';
2
+ import type { StaticRemotesConfig } from '@nx/module-federation/internal';
3
3
  import { ModuleFederationDevServerOptions } from '../module-federation-dev-server/schema';
4
4
  import { ModuleFederationStaticServerSchema } from './schema';
5
5
  export declare function startProxies(staticRemotesConfig: StaticRemotesConfig, hostServeOptions: ModuleFederationDevServerOptions, mappedLocationOfHost: string, mappedLocationsOfRemotes: Record<string, string>, sslOptions?: {
@@ -5,8 +5,8 @@ exports.default = moduleFederationStaticServer;
5
5
  const internal_1 = require("@nx/devkit/internal");
6
6
  const devkit_1 = require("@nx/devkit");
7
7
  const internal_2 = require("@nx/js/internal");
8
- const internal_3 = require("@nx/module-federation/internal");
9
- const internal_4 = require("@nx/web/internal");
8
+ const internal_3 = require("@nx/web/internal");
9
+ const assert_package_1 = require("../../utils/assert-package");
10
10
  const module_federation_deprecation_1 = require("../../utils/module-federation-deprecation");
11
11
  const child_process_1 = require("child_process");
12
12
  const fs_1 = require("fs");
@@ -157,21 +157,26 @@ function startProxies(staticRemotesConfig, hostServeOptions, mappedLocationOfHos
157
157
  devkit_1.logger.info('NX Static Consumer (host) proxy started successfully');
158
158
  }
159
159
  async function* moduleFederationStaticServer(schema, context) {
160
+ const executorName = '@nx/react:module-federation-static-server';
161
+ (0, assert_package_1.assertPackageIsInstalled)('@nx/module-federation', executorName);
162
+ (0, assert_package_1.assertPackageIsInstalled)('express', executorName);
163
+ (0, assert_package_1.assertPackageIsInstalled)('http-proxy-middleware', executorName);
164
+ const { buildStaticRemotes, getModuleFederationConfig, getRemotes, parseStaticRemotesConfig, } = await import('@nx/module-federation/internal');
160
165
  (0, module_federation_deprecation_1.warnReactMfStaticServerExecutorDeprecation)();
161
166
  // Force Node to resolve to look for the nx binary that is inside node_modules
162
167
  const nxBin = require.resolve('nx/bin/nx');
163
168
  // Get the remotes from the module federation config
164
169
  const p = context.projectsConfigurations.projects[context.projectName];
165
170
  const options = getBuildAndServeOptionsFromServeTarget(schema.serveTarget, context);
166
- const moduleFederationConfig = (0, internal_3.getModuleFederationConfig)(options.buildOptions.tsConfig, context.root, p.root, 'react');
167
- const remotes = (0, internal_3.getRemotes)([], options.serveOptions.skipRemotes, moduleFederationConfig, {
171
+ const moduleFederationConfig = getModuleFederationConfig(options.buildOptions.tsConfig, context.root, p.root, 'react');
172
+ const remotes = getRemotes([], options.serveOptions.skipRemotes, moduleFederationConfig, {
168
173
  projectName: context.projectName,
169
174
  projectGraph: context.projectGraph,
170
175
  root: context.root,
171
176
  }, options.pathToManifestFile);
172
- const staticRemotesConfig = (0, internal_3.parseStaticRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
177
+ const staticRemotesConfig = parseStaticRemotesConfig([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
173
178
  options.serveOptions.staticRemotesPort ??= remotes.staticRemotePort;
174
- const mappedLocationsOfStaticRemotes = await (0, internal_3.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options.serveOptions);
179
+ const mappedLocationsOfStaticRemotes = await buildStaticRemotes(staticRemotesConfig, nxBin, context, options.serveOptions);
175
180
  // Build the host
176
181
  const hostUrlSegment = (0, path_1.basename)(options.buildOptions.outputPath);
177
182
  const mappedLocationOfHost = `http${options.serveOptions.ssl ? 's' : ''}://${options.serveOptions.host}:${options.serveOptions.staticRemotesPort}/${hostUrlSegment}`;
@@ -179,7 +184,7 @@ async function* moduleFederationStaticServer(schema, context) {
179
184
  // Move to a temporary directory
180
185
  const commonOutputDirectory = moveToTmpDirectory(staticRemotesConfig, options.buildOptions.outputPath, hostUrlSegment);
181
186
  // File Serve the temporary directory
182
- const staticFileServerIter = (0, internal_4.fileServerExecutor)({
187
+ const staticFileServerIter = (0, internal_3.fileServerExecutor)({
183
188
  cors: true,
184
189
  watch: false,
185
190
  staticFilePath: commonOutputDirectory,
@@ -205,7 +210,7 @@ async function* moduleFederationStaticServer(schema, context) {
205
210
  const baseUrl = `http${options.serveOptions.ssl ? 's' : ''}://${host}:${options.serveOptions.port}`;
206
211
  if (remotes.remotePorts.length === 0) {
207
212
  const portsToWaitFor = [options.serveOptions.staticRemotesPort];
208
- await Promise.all(portsToWaitFor.map((port) => (0, internal_4.waitForPortOpen)(port, {
213
+ await Promise.all(portsToWaitFor.map((port) => (0, internal_3.waitForPortOpen)(port, {
209
214
  retries: 480,
210
215
  retryDelay: 2500,
211
216
  host: host,
@@ -219,7 +224,7 @@ async function* moduleFederationStaticServer(schema, context) {
219
224
  const portsToWaitFor = staticFileServerIter && options.serveOptions.staticRemotesPort
220
225
  ? [options.serveOptions.staticRemotesPort, ...remotes.remotePorts]
221
226
  : [...remotes.remotePorts];
222
- await Promise.all(portsToWaitFor.map((port) => (0, internal_4.waitForPortOpen)(port, {
227
+ await Promise.all(portsToWaitFor.map((port) => (0, internal_3.waitForPortOpen)(port, {
223
228
  retries: 480,
224
229
  retryDelay: 2500,
225
230
  host: host,
@@ -6,9 +6,8 @@ const tslib_1 = require("tslib");
6
6
  const internal_1 = require("@nx/devkit/internal");
7
7
  const assert_supported_react_version_1 = require("../../utils/assert-supported-react-version");
8
8
  const devkit_1 = require("@nx/devkit");
9
- const internal_2 = require("@nx/devkit/internal");
10
9
  const js_1 = require("@nx/js");
11
- const internal_3 = require("@nx/js/internal");
10
+ const internal_2 = require("@nx/js/internal");
12
11
  const create_ts_config_1 = require("../../utils/create-ts-config");
13
12
  const init_1 = tslib_1.__importDefault(require("../init/init"));
14
13
  const create_application_files_1 = require("./lib/create-application-files");
@@ -35,7 +34,7 @@ async function applicationGenerator(tree, schema) {
35
34
  async function applicationGeneratorInternal(tree, schema) {
36
35
  (0, assert_supported_react_version_1.assertSupportedReactVersion)(tree);
37
36
  const tasks = [];
38
- const addTsPlugin = (0, internal_3.shouldConfigureTsSolutionSetup)(tree, schema.addPlugin, schema.useTsSolution);
37
+ const addTsPlugin = (0, internal_2.shouldConfigureTsSolutionSetup)(tree, schema.addPlugin, schema.useTsSolution);
39
38
  const jsInitTask = await (0, js_1.initGenerator)(tree, {
40
39
  ...schema,
41
40
  tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
@@ -76,7 +75,7 @@ async function applicationGeneratorInternal(tree, schema) {
76
75
  const nxJson = (0, devkit_1.readNxJson)(tree) ?? {};
77
76
  const existing = findBuildDefault(nxJson.targetDefaults);
78
77
  if (!existing) {
79
- (0, internal_2.upsertTargetDefault)(tree, nxJson, {
78
+ (0, internal_1.upsertTargetDefault)(tree, nxJson, {
80
79
  target: 'build',
81
80
  cache: true,
82
81
  dependsOn: ['^build'],
@@ -84,7 +83,7 @@ async function applicationGeneratorInternal(tree, schema) {
84
83
  (0, devkit_1.updateNxJson)(tree, nxJson);
85
84
  }
86
85
  else if (!existing.dependsOn) {
87
- (0, internal_2.upsertTargetDefault)(tree, nxJson, {
86
+ (0, internal_1.upsertTargetDefault)(tree, nxJson, {
88
87
  target: 'build',
89
88
  dependsOn: ['^build'],
90
89
  });
@@ -108,7 +107,7 @@ async function applicationGeneratorInternal(tree, schema) {
108
107
  // If we are using the new TS solution
109
108
  // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
110
109
  if (options.isUsingTsSolutionConfig) {
111
- await (0, internal_3.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
110
+ await (0, internal_2.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
112
111
  }
113
112
  const lintTask = await (0, add_linting_1.addLinting)(tree, options);
114
113
  tasks.push(lintTask);
@@ -157,14 +156,14 @@ async function applicationGeneratorInternal(tree, schema) {
157
156
  });
158
157
  }
159
158
  // Only for the new TS solution
160
- (0, internal_3.updateTsconfigFiles)(tree, options.appProjectRoot, 'tsconfig.app.json', {
159
+ (0, internal_2.updateTsconfigFiles)(tree, options.appProjectRoot, 'tsconfig.app.json', {
161
160
  jsx: 'react-jsx',
162
161
  module: 'esnext',
163
162
  moduleResolution: 'bundler',
164
163
  }, options.linter === 'eslint'
165
164
  ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
166
165
  : undefined, options.useReactRouter ? 'app' : 'src');
167
- (0, internal_3.sortPackageJsonFields)(tree, options.appProjectRoot);
166
+ (0, internal_2.sortPackageJsonFields)(tree, options.appProjectRoot);
168
167
  if (!options.skipFormat) {
169
168
  await (0, devkit_1.formatFiles)(tree);
170
169
  }
@@ -20,7 +20,7 @@ export default function handleRequest(
20
20
  responseStatusCode: number,
21
21
  responseHeaders: Headers,
22
22
  routerContext: EntryContext,
23
- loadContext: AppLoadContext
23
+ _loadContext: AppLoadContext
24
24
  ) {
25
25
  return new Promise((resolve, reject) => {
26
26
  let shellRendered = false;
@@ -1,5 +1,5 @@
1
1
  import { createRoutesStub } from 'react-router';
2
- import { render, screen, waitFor } from '@testing-library/react';
2
+ import { render, screen } from '@testing-library/react';
3
3
  import App from '../../app/app';
4
4
 
5
5
  test('renders loader data', async () => {
@@ -12,5 +12,5 @@ test('renders loader data', async () => {
12
12
 
13
13
  render(<ReactRouterStub />);
14
14
 
15
- await waitFor(() => screen.findByText('Hello there,'));
15
+ expect(await screen.findByText('Hello there,')).toBeTruthy();
16
16
  });
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addE2e = addE2e;
4
+ const internal_1 = require("@nx/eslint/internal");
4
5
  const devkit_1 = require("@nx/devkit");
5
6
  const web_1 = require("@nx/web");
6
7
  const versions_1 = require("../../../utils/versions");
@@ -92,6 +93,7 @@ async function addE2e(tree, options) {
92
93
  baseUrl: e2eWebServerInfo.e2eWebServerAddress,
93
94
  jsx: true,
94
95
  rootProject: options.rootProject,
96
+ enableTypedLinting: (0, internal_1.isTypedLintingEnabled)(options),
95
97
  webServerCommands: {
96
98
  default: e2eWebServerInfo.e2eWebServerCommand,
97
99
  production: e2eWebServerInfo.e2eCiWebServerCommand,
@@ -133,7 +135,7 @@ async function addE2e(tree, options) {
133
135
  directory: 'src',
134
136
  js: false,
135
137
  linter: options.linter,
136
- setParserOptionsProject: options.setParserOptionsProject,
138
+ enableTypedLinting: (0, internal_1.isTypedLintingEnabled)(options),
137
139
  webServerCommand: e2eWebServerInfo.e2eCiWebServerCommand,
138
140
  webServerAddress: e2eWebServerInfo.e2eCiBaseUrl,
139
141
  rootProject: options.rootProject,
@@ -5,7 +5,6 @@ exports.isEslintInstalled = isEslintInstalled;
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const eslint_1 = require("@nx/eslint");
7
7
  const internal_1 = require("@nx/eslint/internal");
8
- const devkit_2 = require("@nx/devkit");
9
8
  const internal_2 = require("@nx/js/internal");
10
9
  const lint_1 = require("../../../utils/lint");
11
10
  const versions_1 = require("../../../utils/versions");
@@ -22,6 +21,7 @@ async function addLinting(host, options) {
22
21
  skipFormat: true,
23
22
  rootProject: options.rootProject,
24
23
  skipPackageJson: options.skipPackageJson,
24
+ enableTypedLinting: (0, internal_1.isTypedLintingEnabled)(options),
25
25
  addPlugin: options.addPlugin,
26
26
  });
27
27
  tasks.push(lintTask);
@@ -40,7 +40,7 @@ async function addLinting(host, options) {
40
40
  }
41
41
  }
42
42
  if (!options.skipPackageJson) {
43
- const installTask = (0, devkit_2.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies, undefined, true);
43
+ const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies, undefined, true);
44
44
  const addSwcTask = (0, internal_2.addSwcDependencies)(host);
45
45
  tasks.push(installTask, addSwcTask);
46
46
  }
@@ -48,7 +48,7 @@ async function addLinting(host, options) {
48
48
  await ignoreReactRouterFilesInEslintConfig(host, options.appProjectRoot);
49
49
  }
50
50
  }
51
- return (0, devkit_2.runTasksInSerial)(...tasks);
51
+ return (0, devkit_1.runTasksInSerial)(...tasks);
52
52
  }
53
53
  async function ignoreReactRouterFilesInEslintConfig(tree, projectRoot) {
54
54
  if (!isEslintInstalled(tree)) {
@@ -19,6 +19,7 @@ export declare function getDefaultTemplateVariables(host: Tree, options: Normali
19
19
  skipNxJson?: boolean;
20
20
  globalCss?: boolean;
21
21
  strict?: boolean;
22
+ enableTypedLinting?: boolean;
22
23
  setParserOptionsProject?: boolean;
23
24
  compiler?: 'babel' | 'swc';
24
25
  remotes?: string[];
@@ -11,10 +11,10 @@ const get_in_source_vitest_tests_template_1 = require("../../../utils/get-in-sou
11
11
  const maybe_js_1 = require("../../../utils/maybe-js");
12
12
  const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
13
13
  const get_app_tests_1 = require("./get-app-tests");
14
- const onboarding_1 = require("nx/src/nx-cloud/utilities/onboarding");
15
14
  const has_rspack_plugin_1 = require("../../../utils/has-rspack-plugin");
16
15
  const internal_1 = require("@nx/js/internal");
17
16
  const versions_1 = require("../../../utils/versions");
17
+ const internal_2 = require("@nx/devkit/internal");
18
18
  function getDefaultTemplateVariables(host, options) {
19
19
  const hasStyleFile = ['scss', 'css'].includes(options.style);
20
20
  const appTests = (0, get_app_tests_1.getAppTests)(options);
@@ -69,9 +69,9 @@ async function createApplicationFiles(host, options) {
69
69
  else {
70
70
  styleSolutionSpecificAppFiles = '../files/style-css-module';
71
71
  }
72
- const onBoardingStatus = await (0, onboarding_1.createNxCloudOnboardingURLForWelcomeApp)(host, options.nxCloudToken);
72
+ const onBoardingStatus = await (0, internal_2.createNxCloudOnboardingURLForWelcomeApp)(host, options.nxCloudToken);
73
73
  const connectCloudUrl = onBoardingStatus === 'unclaimed' &&
74
- (await (0, onboarding_1.getNxCloudAppOnBoardingUrl)(options.nxCloudToken));
74
+ (await (0, internal_2.getNxCloudAppOnBoardingUrl)(options.nxCloudToken));
75
75
  const relativePathToRootTsConfig = (0, js_1.getRelativePathToRootTsConfig)(host, options.appProjectRoot);
76
76
  const templateVariables = getDefaultTemplateVariables(host, options);
77
77
  if (options.bundler === 'vite' && !options.useReactRouter) {
@@ -1,2 +1,2 @@
1
- import { Tree } from 'nx/src/generators/tree';
1
+ import { Tree } from '@nx/devkit';
2
2
  export declare function findFreePort(host: Tree): number;
@@ -19,6 +19,10 @@ export interface Schema {
19
19
  js?: boolean;
20
20
  globalCss?: boolean;
21
21
  strict?: boolean;
22
+ enableTypedLinting?: boolean;
23
+ /**
24
+ * @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
25
+ */
22
26
  setParserOptionsProject?: boolean;
23
27
  compiler?: 'babel' | 'swc';
24
28
  remotes?: string[];
@@ -150,11 +150,17 @@
150
150
  "description": "Creates an application with strict mode and strict type checking.",
151
151
  "default": true
152
152
  },
153
- "setParserOptionsProject": {
153
+ "enableTypedLinting": {
154
154
  "type": "boolean",
155
- "description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
155
+ "description": "Whether to enable typed linting. For flat configs, this configures the recommended `parserOptions.projectService` and `tsconfigRootDir`. For legacy `.eslintrc` configs, this configures `parserOptions.project`. We do not enable this by default for lint performance reasons.",
156
156
  "default": false
157
157
  },
158
+ "setParserOptionsProject": {
159
+ "type": "boolean",
160
+ "description": "Deprecated alias for `enableTypedLinting`.",
161
+ "default": false,
162
+ "x-deprecated": "Use `enableTypedLinting` instead. This option will be removed in Nx v24."
163
+ },
158
164
  "compiler": {
159
165
  "type": "string",
160
166
  "description": "The compiler to use.",
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addFiles = addFiles;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const internal_1 = require("@nx/js/internal");
6
- const versions_1 = require("nx/src/utils/versions");
7
6
  const ct_utils_1 = require("../../../utils/ct-utils");
8
7
  const component_test_1 = require("../../component-test/component-test");
8
+ const internal_2 = require("@nx/devkit/internal");
9
9
  async function addFiles(tree, projectConfig, options, found) {
10
10
  // must dynamicaly import to prevent packages not using cypress from erroring out
11
11
  // when importing react
@@ -24,11 +24,11 @@ async function addFiles(tree, projectConfig, options, found) {
24
24
  tree.write(commandFile, `import { mount } from '${moduleSpecifier}';\n${updatedCommandFile}`);
25
25
  if (options.bundler === 'webpack' ||
26
26
  (!options.bundler && actualBundler === 'webpack')) {
27
- (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/webpack': versions_1.nxVersion }, undefined, true);
27
+ (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/webpack': internal_2.nxVersion }, undefined, true);
28
28
  }
29
29
  if (options.bundler === 'vite' ||
30
30
  (!options.bundler && actualBundler === 'vite')) {
31
- (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/vite': versions_1.nxVersion }, undefined, true);
31
+ (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/vite': internal_2.nxVersion }, undefined, true);
32
32
  }
33
33
  if (options.generateTests) {
34
34
  const filePaths = [];
@@ -4,6 +4,7 @@ exports.hostGenerator = hostGenerator;
4
4
  const tslib_1 = require("tslib");
5
5
  const internal_1 = require("@nx/devkit/internal");
6
6
  const assert_supported_react_version_1 = require("../../utils/assert-supported-react-version");
7
+ const internal_2 = require("@nx/eslint/internal");
7
8
  const devkit_1 = require("@nx/devkit");
8
9
  const update_module_federation_project_1 = require("../../rules/update-module-federation-project");
9
10
  const application_1 = tslib_1.__importDefault(require("../application/application"));
@@ -16,7 +17,7 @@ const setup_ssr_for_host_1 = require("./lib/setup-ssr-for-host");
16
17
  const update_module_federation_e2e_project_1 = require("./lib/update-module-federation-e2e-project");
17
18
  const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
18
19
  const js_1 = require("@nx/js");
19
- const internal_2 = require("@nx/js/internal");
20
+ const internal_3 = require("@nx/js/internal");
20
21
  const versions_1 = require("../../utils/versions");
21
22
  const update_module_federation_tsconfig_1 = require("./lib/update-module-federation-tsconfig");
22
23
  const normalize_host_name_1 = require("./lib/normalize-host-name");
@@ -61,7 +62,7 @@ async function hostGenerator(host, schema) {
61
62
  });
62
63
  tasks.push(initTask);
63
64
  // In TS solution setup, update package.json to use simple name instead of scoped name
64
- if ((0, internal_2.isUsingTsSolutionSetup)(host)) {
65
+ if ((0, internal_3.isUsingTsSolutionSetup)(host)) {
65
66
  const hostPackageJsonPath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json');
66
67
  if (host.exists(hostPackageJsonPath)) {
67
68
  (0, devkit_1.updateJson)(host, hostPackageJsonPath, (json) => {
@@ -102,7 +103,7 @@ async function hostGenerator(host, schema) {
102
103
  (0, update_module_federation_e2e_project_1.updateModuleFederationE2eProject)(host, options);
103
104
  (0, update_module_federation_tsconfig_1.updateModuleFederationTsconfig)(host, options);
104
105
  // Add remotes as devDependencies in TS solution setup
105
- if ((0, internal_2.isUsingTsSolutionSetup)(host) && remotesWithPorts.length > 0) {
106
+ if ((0, internal_3.isUsingTsSolutionSetup)(host) && remotesWithPorts.length > 0) {
106
107
  addRemotesAsHostDependencies(host, options.projectName, remotesWithPorts);
107
108
  }
108
109
  if (options.ssr) {
@@ -122,13 +123,21 @@ async function hostGenerator(host, schema) {
122
123
  }
123
124
  (0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfig);
124
125
  }
125
- if (!options.setParserOptionsProject) {
126
+ if (!(0, internal_2.isTypedLintingEnabled)(options)) {
126
127
  host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.lint.json'));
127
128
  }
128
129
  (0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host, options.bundler);
129
130
  const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, { '@module-federation/enhanced': versions_1.moduleFederationEnhancedVersion }, {
130
131
  '@nx/web': versions_1.nxVersion,
131
132
  '@nx/module-federation': versions_1.nxVersion,
133
+ // The webpack path also generates a `serve-static` target running the
134
+ // `module-federation-static-server` executor, which proxies via express.
135
+ ...(options.bundler !== 'rspack'
136
+ ? {
137
+ express: versions_1.expressVersion,
138
+ 'http-proxy-middleware': versions_1.httpProxyMiddlewareVersion,
139
+ }
140
+ : {}),
132
141
  }, undefined, true);
133
142
  tasks.push(installTask);
134
143
  if (!options.skipFormat) {
@@ -2,16 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setupSsrForHost = setupSsrForHost;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const devkit_2 = require("@nx/devkit");
6
5
  const versions_1 = require("../../../utils/versions");
7
6
  const create_application_files_1 = require("../../application/lib/create-application-files");
8
7
  async function setupSsrForHost(tree, options, appName, defaultRemoteManifest) {
9
8
  const tasks = [];
10
- let project = (0, devkit_2.readProjectConfiguration)(tree, appName);
9
+ let project = (0, devkit_1.readProjectConfiguration)(tree, appName);
11
10
  if (options.bundler !== 'rspack') {
12
11
  project.targets.serve.executor =
13
12
  '@nx/react:module-federation-ssr-dev-server';
14
- (0, devkit_2.updateProjectConfiguration)(tree, appName, project);
13
+ (0, devkit_1.updateProjectConfiguration)(tree, appName, project);
15
14
  }
16
15
  const pathToModuleFederationSsrFiles = options.typescriptConfiguration
17
16
  ? `${options.bundler === 'rspack' ? 'rspack-' : 'webpack-'}module-federation-ssr-ts`
@@ -28,7 +27,7 @@ async function setupSsrForHost(tree, options, appName, defaultRemoteManifest) {
28
27
  static: !options?.dynamic,
29
28
  remotes: defaultRemoteManifest.map(({ name, port }) => {
30
29
  return {
31
- ...(0, devkit_2.names)(name),
30
+ ...(0, devkit_1.names)(name),
32
31
  port,
33
32
  };
34
33
  }),
@@ -42,13 +41,13 @@ async function setupSsrForHost(tree, options, appName, defaultRemoteManifest) {
42
41
  browserBuildOutputPath: project.targets.build?.options?.outputPath,
43
42
  remotes: defaultRemoteManifest.map(({ name, port }) => {
44
43
  return {
45
- ...(0, devkit_2.names)(name),
44
+ ...(0, devkit_1.names)(name),
46
45
  port,
47
46
  };
48
47
  }),
49
48
  };
50
- (0, devkit_2.generateFiles)(tree, (0, devkit_2.joinPathFragments)(__dirname, `../files/${pathToModuleFederationSsrFiles}`), project.root, templateVariables);
51
- const installTask = (0, devkit_2.addDependenciesToPackageJson)(tree, {
49
+ (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, `../files/${pathToModuleFederationSsrFiles}`), project.root, templateVariables);
50
+ const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
52
51
  '@module-federation/node': versions_1.moduleFederationNodeVersion,
53
52
  cors: versions_1.corsVersion,
54
53
  isbot: versions_1.isbotVersion,
@@ -56,5 +55,5 @@ async function setupSsrForHost(tree, options, appName, defaultRemoteManifest) {
56
55
  '@types/express': versions_1.typesExpressVersion,
57
56
  }, {}, undefined, true);
58
57
  tasks.push(installTask);
59
- return (0, devkit_2.runTasksInSerial)(...tasks);
58
+ return (0, devkit_1.runTasksInSerial)(...tasks);
60
59
  }
@@ -12,6 +12,10 @@ export interface Schema {
12
12
  linter: Linter | LinterType;
13
13
  name?: string;
14
14
  remotes?: string[];
15
+ enableTypedLinting?: boolean;
16
+ /**
17
+ * @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
18
+ */
15
19
  setParserOptionsProject?: boolean;
16
20
  skipFormat?: boolean;
17
21
  skipNxJson?: boolean;