@nx/react 23.2.0-beta.0 → 23.2.0-beta.10

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 (68) 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 +12 -25
  11. package/dist/src/generators/application/files/nx-welcome/claimed/src/app/nx-welcome.tsx__tmpl__ +2 -0
  12. package/dist/src/generators/application/files/nx-welcome/not-configured/src/app/nx-welcome.tsx__tmpl__ +2 -0
  13. package/dist/src/generators/application/files/nx-welcome/unclaimed/src/app/nx-welcome.tsx__tmpl__ +2 -0
  14. package/dist/src/generators/application/files/react-router-ssr/common/app/entry.server.tsx__tmpl__ +1 -1
  15. package/dist/src/generators/application/files/react-router-ssr/common/tests/routes/_index.spec.tsx__tmpl__ +2 -2
  16. package/dist/src/generators/application/files/react-router-ssr/nx-welcome/claimed/app/nx-welcome.tsx__tmpl__ +2 -0
  17. package/dist/src/generators/application/files/react-router-ssr/nx-welcome/not-configured/app/nx-welcome.tsx__tmpl__ +2 -0
  18. package/dist/src/generators/application/files/react-router-ssr/nx-welcome/unclaimed/app/nx-welcome.tsx__tmpl__ +2 -0
  19. package/dist/src/generators/application/lib/add-e2e.js +3 -1
  20. package/dist/src/generators/application/lib/add-linting.d.ts +0 -1
  21. package/dist/src/generators/application/lib/add-linting.js +21 -31
  22. package/dist/src/generators/application/lib/create-application-files.d.ts +3 -2
  23. package/dist/src/generators/application/lib/create-application-files.js +3 -3
  24. package/dist/src/generators/application/lib/find-free-port.d.ts +1 -1
  25. package/dist/src/generators/application/lib/normalize-options.js +15 -11
  26. package/dist/src/generators/application/schema.d.ts +9 -3
  27. package/dist/src/generators/application/schema.json +15 -6
  28. package/dist/src/generators/cypress-component-configuration/lib/add-files.js +3 -3
  29. package/dist/src/generators/federate-module/schema.d.ts +2 -2
  30. package/dist/src/generators/federate-module/schema.json +3 -4
  31. package/dist/src/generators/host/files/rspack-module-federation/module-federation.config.js__tmpl__ +1 -1
  32. package/dist/src/generators/host/host.js +13 -4
  33. package/dist/src/generators/host/lib/setup-ssr-for-host.js +7 -8
  34. package/dist/src/generators/host/schema.d.ts +8 -2
  35. package/dist/src/generators/host/schema.json +11 -6
  36. package/dist/src/generators/library/lib/add-linting.d.ts +1 -2
  37. package/dist/src/generators/library/lib/add-linting.js +28 -30
  38. package/dist/src/generators/library/lib/add-rollup-build-target.d.ts +1 -2
  39. package/dist/src/generators/library/lib/determine-entry-fields.d.ts +1 -1
  40. package/dist/src/generators/library/lib/normalize-options.js +28 -21
  41. package/dist/src/generators/library/lib/update-app-routes.js +1 -2
  42. package/dist/src/generators/library/schema.d.ts +8 -2
  43. package/dist/src/generators/library/schema.json +10 -6
  44. package/dist/src/generators/remote/lib/setup-ssr-for-remote.js +8 -9
  45. package/dist/src/generators/remote/lib/setup-tspath-for-remote.js +3 -2
  46. package/dist/src/generators/remote/remote.js +15 -6
  47. package/dist/src/generators/remote/schema.d.ts +6 -2
  48. package/dist/src/generators/remote/schema.json +11 -6
  49. package/dist/src/generators/storybook-configuration/schema.d.ts +2 -2
  50. package/dist/src/generators/storybook-configuration/schema.json +1 -2
  51. package/dist/src/migrations/update-23-2-0/add-optional-module-federation-packages.d.ts +2 -0
  52. package/dist/src/migrations/update-23-2-0/add-optional-module-federation-packages.js +61 -0
  53. package/dist/src/migrations/update-23-2-0/add-optional-module-federation-packages.md +37 -0
  54. package/dist/src/migrations/update-23-2-0/add-svgr-webpack-if-used.d.ts +2 -0
  55. package/dist/src/migrations/update-23-2-0/add-svgr-webpack-if-used.js +55 -0
  56. package/dist/src/migrations/update-23-2-0/add-svgr-webpack-if-used.md +28 -0
  57. package/dist/src/plugins/router-plugin.js +2 -4
  58. package/dist/src/utils/assert-package.d.ts +1 -0
  59. package/dist/src/utils/assert-package.js +17 -0
  60. package/dist/src/utils/ast-utils.js +2 -2
  61. package/dist/src/utils/create-ts-config.d.ts +1 -1
  62. package/dist/src/utils/create-ts-config.js +5 -5
  63. package/dist/src/utils/versions.d.ts +2 -0
  64. package/dist/src/utils/versions.js +3 -1
  65. package/migrations.json +12 -0
  66. package/package.json +32 -20
  67. /package/dist/src/generators/consumer/files/vite/{vite.config.ts__tmpl__ → vite.config.mts__tmpl__} +0 -0
  68. /package/dist/src/generators/provider/files/vite/{vite.config.ts__tmpl__ → vite.config.mts__tmpl__} +0 -0
@@ -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,13 +34,12 @@ 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',
42
41
  skipFormat: true,
43
42
  addTsPlugin,
44
- formatter: schema.formatter,
45
43
  platform: 'web',
46
44
  });
47
45
  tasks.push(jsInitTask);
@@ -49,22 +47,11 @@ async function applicationGeneratorInternal(tree, schema) {
49
47
  options.useReactRouter =
50
48
  options.routing && options.bundler === 'vite'
51
49
  ? (options.useReactRouter ??
52
- (await (0, internal_1.promptWhenInteractive)({
53
- name: 'response',
54
- message: 'Would you like to use react-router for server-side rendering?',
55
- type: 'autocomplete',
56
- choices: [
57
- {
58
- name: 'Yes',
59
- message: 'I want to use react-router [ https://reactrouter.com/start/framework/routing ]',
60
- },
61
- {
62
- name: 'No',
63
- message: 'I do not want to use react-router for server-side rendering',
64
- },
65
- ],
66
- initial: 0,
67
- }, { response: 'No' }).then((r) => r.response === 'Yes')))
50
+ ((0, internal_1.isInteractive)()
51
+ ? await (0, internal_1.confirmationPrompt)({
52
+ message: 'Would you like to use react-router for server-side rendering?',
53
+ })
54
+ : false))
68
55
  : false;
69
56
  const initTask = await (0, init_1.default)(tree, {
70
57
  ...options,
@@ -76,7 +63,7 @@ async function applicationGeneratorInternal(tree, schema) {
76
63
  const nxJson = (0, devkit_1.readNxJson)(tree) ?? {};
77
64
  const existing = findBuildDefault(nxJson.targetDefaults);
78
65
  if (!existing) {
79
- (0, internal_2.upsertTargetDefault)(tree, nxJson, {
66
+ (0, internal_1.upsertTargetDefault)(tree, nxJson, {
80
67
  target: 'build',
81
68
  cache: true,
82
69
  dependsOn: ['^build'],
@@ -84,7 +71,7 @@ async function applicationGeneratorInternal(tree, schema) {
84
71
  (0, devkit_1.updateNxJson)(tree, nxJson);
85
72
  }
86
73
  else if (!existing.dependsOn) {
87
- (0, internal_2.upsertTargetDefault)(tree, nxJson, {
74
+ (0, internal_1.upsertTargetDefault)(tree, nxJson, {
88
75
  target: 'build',
89
76
  dependsOn: ['^build'],
90
77
  });
@@ -108,7 +95,7 @@ async function applicationGeneratorInternal(tree, schema) {
108
95
  // If we are using the new TS solution
109
96
  // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
110
97
  if (options.isUsingTsSolutionConfig) {
111
- await (0, internal_3.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
98
+ await (0, internal_2.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
112
99
  }
113
100
  const lintTask = await (0, add_linting_1.addLinting)(tree, options);
114
101
  tasks.push(lintTask);
@@ -157,14 +144,14 @@ async function applicationGeneratorInternal(tree, schema) {
157
144
  });
158
145
  }
159
146
  // Only for the new TS solution
160
- (0, internal_3.updateTsconfigFiles)(tree, options.appProjectRoot, 'tsconfig.app.json', {
147
+ (0, internal_2.updateTsconfigFiles)(tree, options.appProjectRoot, 'tsconfig.app.json', {
161
148
  jsx: 'react-jsx',
162
149
  module: 'esnext',
163
150
  moduleResolution: 'bundler',
164
151
  }, options.linter === 'eslint'
165
152
  ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
166
153
  : undefined, options.useReactRouter ? 'app' : 'src');
167
- (0, internal_3.sortPackageJsonFields)(tree, options.appProjectRoot);
154
+ (0, internal_2.sortPackageJsonFields)(tree, options.appProjectRoot);
168
155
  if (!options.skipFormat) {
169
156
  await (0, devkit_1.formatFiles)(tree);
170
157
  }
@@ -5,6 +5,8 @@
5
5
  Delete this file and get started with your project!
6
6
  * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7
7
  */
8
+ /* oxlint-disable jsx-a11y/prefer-tag-over-role -- the icons below
9
+ are inline SVGs, which have no tag to swap the role for. */
8
10
  export function NxWelcome({ title }: { title: string }) {
9
11
  return (
10
12
  <>
@@ -5,6 +5,8 @@
5
5
  Delete this file and get started with your project!
6
6
  * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7
7
  */
8
+ /* oxlint-disable jsx-a11y/prefer-tag-over-role -- the icons below
9
+ are inline SVGs, which have no tag to swap the role for. */
8
10
  export function NxWelcome({ title }: { title: string }) {
9
11
  return (
10
12
  <>
@@ -5,6 +5,8 @@
5
5
  Delete this file and get started with your project!
6
6
  * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7
7
  */
8
+ /* oxlint-disable jsx-a11y/prefer-tag-over-role -- the icons below
9
+ are inline SVGs, which have no tag to swap the role for. */
8
10
  export function NxWelcome({ title }: { title: string }) {
9
11
  return (
10
12
  <>
@@ -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
  });
@@ -5,6 +5,8 @@
5
5
  Delete this file and get started with your project!
6
6
  * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7
7
  */
8
+ /* oxlint-disable jsx-a11y/prefer-tag-over-role -- the icons below
9
+ are inline SVGs, which have no tag to swap the role for. */
8
10
  export function NxWelcome({ title }: { title: string }) {
9
11
  return (
10
12
  <>
@@ -5,6 +5,8 @@
5
5
  Delete this file and get started with your project!
6
6
  * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7
7
  */
8
+ /* oxlint-disable jsx-a11y/prefer-tag-over-role -- the icons below
9
+ are inline SVGs, which have no tag to swap the role for. */
8
10
  export function NxWelcome({ title }: { title: string }) {
9
11
  return (
10
12
  <>
@@ -5,6 +5,8 @@
5
5
  Delete this file and get started with your project!
6
6
  * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7
7
  */
8
+ /* oxlint-disable jsx-a11y/prefer-tag-over-role -- the icons below
9
+ are inline SVGs, which have no tag to swap the role for. */
8
10
  export function NxWelcome({ title }: { title: string }) {
9
11
  return (
10
12
  <>
@@ -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,
@@ -1,4 +1,3 @@
1
1
  import { type Tree, type GeneratorCallback } from '@nx/devkit';
2
2
  import { NormalizedSchema } from '../schema';
3
3
  export declare function addLinting(host: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
4
- export declare function isEslintInstalled(tree: Tree): boolean;
@@ -1,30 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addLinting = addLinting;
4
- exports.isEslintInstalled = isEslintInstalled;
5
4
  const devkit_1 = require("@nx/devkit");
6
- const eslint_1 = require("@nx/eslint");
7
5
  const internal_1 = require("@nx/eslint/internal");
8
- const devkit_2 = require("@nx/devkit");
9
6
  const internal_2 = require("@nx/js/internal");
10
7
  const lint_1 = require("../../../utils/lint");
11
8
  const versions_1 = require("../../../utils/versions");
12
9
  async function addLinting(host, options) {
10
+ if (options.linter === 'none') {
11
+ return () => { };
12
+ }
13
13
  const tasks = [];
14
+ tasks.push(await (0, internal_2.addLintingToProject)(host, {
15
+ oxlintPlugins: ['react', 'react-perf', 'jsx-a11y'],
16
+ linter: options.linter,
17
+ project: options.projectName,
18
+ tsConfigPaths: [
19
+ (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
20
+ ],
21
+ unitTestRunner: options.unitTestRunner,
22
+ rootProject: options.rootProject,
23
+ skipPackageJson: options.skipPackageJson,
24
+ enableTypedLinting: (0, internal_1.isTypedLintingEnabled)(options),
25
+ addPlugin: options.addPlugin,
26
+ }));
27
+ // Predefined configs, `extends` and ignore entries are ESLint concepts with
28
+ // no equivalent in other linters.
14
29
  if (options.linter === 'eslint') {
15
- const lintTask = await (0, eslint_1.lintProjectGenerator)(host, {
16
- linter: options.linter,
17
- project: options.projectName,
18
- tsConfigPaths: [
19
- (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
20
- ],
21
- unitTestRunner: options.unitTestRunner,
22
- skipFormat: true,
23
- rootProject: options.rootProject,
24
- skipPackageJson: options.skipPackageJson,
25
- addPlugin: options.addPlugin,
26
- });
27
- tasks.push(lintTask);
28
30
  if ((0, internal_1.isEslintConfigSupported)(host)) {
29
31
  if ((0, internal_1.useFlatConfig)(host)) {
30
32
  (0, internal_1.addPredefinedConfigToFlatLintConfig)(host, options.appProjectRoot, 'flat/react', { checkBaseConfig: true });
@@ -40,7 +42,7 @@ async function addLinting(host, options) {
40
42
  }
41
43
  }
42
44
  if (!options.skipPackageJson) {
43
- const installTask = (0, devkit_2.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies, undefined, true);
45
+ const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies, undefined, true);
44
46
  const addSwcTask = (0, internal_2.addSwcDependencies)(host);
45
47
  tasks.push(installTask, addSwcTask);
46
48
  }
@@ -48,10 +50,10 @@ async function addLinting(host, options) {
48
50
  await ignoreReactRouterFilesInEslintConfig(host, options.appProjectRoot);
49
51
  }
50
52
  }
51
- return (0, devkit_2.runTasksInSerial)(...tasks);
53
+ return (0, devkit_1.runTasksInSerial)(...tasks);
52
54
  }
53
55
  async function ignoreReactRouterFilesInEslintConfig(tree, projectRoot) {
54
- if (!isEslintInstalled(tree)) {
56
+ if (!(0, internal_2.detectLinters)(tree).includes('eslint')) {
55
57
  return;
56
58
  }
57
59
  (0, devkit_1.ensurePackage)('@nx/eslint', versions_1.nxVersion);
@@ -70,15 +72,3 @@ async function ignoreReactRouterFilesInEslintConfig(tree, projectRoot) {
70
72
  const directory = isUsingFlatConfig ? '' : (projectRoot ?? '');
71
73
  addIgnoresToLintConfig(tree, directory, ['**/build', '**/.react-router']);
72
74
  }
73
- function isEslintInstalled(tree) {
74
- try {
75
- require('eslint');
76
- return true;
77
- }
78
- catch { }
79
- // it might not be installed yet, but it might be in the tree pending install
80
- const { devDependencies, dependencies } = tree.exists('package.json')
81
- ? (0, devkit_1.readJson)(tree, 'package.json')
82
- : {};
83
- return !!devDependencies?.['eslint'] || !!dependencies?.['eslint'];
84
- }
@@ -12,13 +12,13 @@ export declare function getDefaultTemplateVariables(host: Tree, options: Normali
12
12
  tags?: string;
13
13
  inSourceTests?: boolean;
14
14
  e2eTestRunner: 'cypress' | 'playwright' | 'none';
15
- linter: import("@nx/eslint").Linter | import("@nx/eslint").LinterType;
16
15
  classComponent?: boolean;
17
16
  routing?: boolean;
18
17
  useReactRouter?: boolean;
19
18
  skipNxJson?: boolean;
20
19
  globalCss?: boolean;
21
20
  strict?: boolean;
21
+ enableTypedLinting?: boolean;
22
22
  setParserOptionsProject?: boolean;
23
23
  compiler?: 'babel' | 'swc';
24
24
  remotes?: string[];
@@ -29,8 +29,9 @@ export declare function getDefaultTemplateVariables(host: Tree, options: Normali
29
29
  minimal?: boolean;
30
30
  nxCloudToken?: string;
31
31
  useTsSolution?: boolean;
32
- formatter?: 'prettier' | 'none';
32
+ formatter?: 'prettier' | 'oxfmt' | 'none';
33
33
  useProjectJson?: boolean;
34
+ linter: import("@nx/js").LinterType;
34
35
  projectName: string;
35
36
  appProjectRoot: string;
36
37
  e2eProjectName: 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;
@@ -46,17 +46,21 @@ async function normalizeOptions(host, options) {
46
46
  names: (0, devkit_1.names)(projectNames.projectSimpleName),
47
47
  isUsingTsSolutionConfig,
48
48
  useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
49
+ routing: options.routing ?? false,
50
+ useReactRouter: options.useReactRouter ?? false,
51
+ strict: options.strict ?? true,
52
+ classComponent: options.classComponent ?? false,
53
+ compiler: options.compiler ?? 'babel',
54
+ bundler: options.bundler ?? 'webpack',
55
+ unitTestRunner: options.unitTestRunner ?? 'jest',
56
+ e2eTestRunner: options.e2eTestRunner ?? 'playwright',
57
+ inSourceTests: options.minimal || options.inSourceTests,
58
+ devServerPort: options.devServerPort ?? options.port ?? (0, find_free_port_1.findFreePort)(host),
59
+ minimal: options.minimal ?? false,
60
+ // Programmatic callers such as the host and remote generators leave this
61
+ // unset; the guards downstream read an unresolved `undefined` as "not eslint"
62
+ // and would half-configure the project.
63
+ linter: await (0, internal_2.normalizeLinterOption)(host, options.linter),
49
64
  };
50
- normalized.routing = normalized.routing ?? false;
51
- normalized.useReactRouter = normalized.useReactRouter ?? false;
52
- normalized.strict = normalized.strict ?? true;
53
- normalized.classComponent = normalized.classComponent ?? false;
54
- normalized.compiler = normalized.compiler ?? 'babel';
55
- normalized.bundler = normalized.bundler ?? 'webpack';
56
- normalized.unitTestRunner = normalized.unitTestRunner ?? 'jest';
57
- normalized.e2eTestRunner = normalized.e2eTestRunner ?? 'playwright';
58
- normalized.inSourceTests = normalized.minimal || normalized.inSourceTests;
59
- normalized.devServerPort ??= options.port ?? (0, find_free_port_1.findFreePort)(host);
60
- normalized.minimal = normalized.minimal ?? false;
61
65
  return normalized;
62
66
  }