@nx/react 17.0.4 → 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 -12
  17. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +51 -149
  18. package/src/executors/module-federation-dev-server/schema.json +1 -9
  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
@@ -4,20 +4,13 @@ exports.addE2e = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const web_1 = require("@nx/web");
6
6
  const versions_1 = require("../../../utils/versions");
7
- const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
8
- const has_vite_plugin_1 = require("../../../utils/has-vite-plugin");
9
7
  async function addE2e(tree, options) {
10
8
  switch (options.e2eTestRunner) {
11
9
  case 'cypress': {
12
- const hasNxBuildPlugin = (options.bundler === 'webpack' && (0, has_webpack_plugin_1.hasWebpackPlugin)(tree)) ||
13
- (options.bundler === 'vite' && (0, has_vite_plugin_1.hasVitePlugin)(tree));
14
- if (!hasNxBuildPlugin) {
15
- await (0, web_1.webStaticServeGenerator)(tree, {
16
- buildTarget: `${options.projectName}:build`,
17
- targetName: 'serve-static',
18
- spa: true,
19
- });
20
- }
10
+ (0, web_1.webStaticServeGenerator)(tree, {
11
+ buildTarget: `${options.projectName}:build`,
12
+ targetName: 'serve-static',
13
+ });
21
14
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
22
15
  (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
23
16
  projectType: 'application',
@@ -34,19 +27,9 @@ async function addE2e(tree, options) {
34
27
  // the name and root are already normalized, instruct the generator to use them as is
35
28
  bundler: options.bundler === 'rspack' ? 'webpack' : options.bundler,
36
29
  skipFormat: true,
37
- devServerTarget: `${options.projectName}:${options.e2eWebServerTarget}`,
38
- baseUrl: options.e2eWebServerAddress,
30
+ devServerTarget: `${options.projectName}:serve`,
39
31
  jsx: true,
40
32
  rootProject: options.rootProject,
41
- webServerCommands: hasNxBuildPlugin
42
- ? {
43
- default: `nx run ${options.projectName}:${options.e2eWebServerTarget}`,
44
- production: `nx run ${options.projectName}:preview`,
45
- }
46
- : undefined,
47
- ciWebServerCommand: hasNxBuildPlugin
48
- ? `nx run ${options.projectName}:serve-static`
49
- : undefined,
50
33
  });
51
34
  }
52
35
  case 'playwright': {
@@ -66,10 +49,9 @@ async function addE2e(tree, options) {
66
49
  js: false,
67
50
  linter: options.linter,
68
51
  setParserOptionsProject: options.setParserOptionsProject,
69
- webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx ${options.e2eWebServerTarget} ${options.name}`,
70
- webServerAddress: options.e2eWebServerAddress,
52
+ webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx serve ${options.name}`,
53
+ webServerAddress: 'http://localhost:4200',
71
54
  rootProject: options.rootProject,
72
- addPlugin: options.addPlugin,
73
55
  });
74
56
  }
75
57
  case 'none':
@@ -4,10 +4,10 @@ exports.addJest = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const versions_1 = require("../../../utils/versions");
6
6
  async function addJest(host, options) {
7
- if (options.unitTestRunner === 'none') {
7
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
8
+ if (options.unitTestRunner !== 'jest') {
8
9
  return () => { };
9
10
  }
10
- const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
11
11
  return await configurationGenerator(host, {
12
12
  ...options,
13
13
  project: options.projectName,
@@ -1,3 +1,3 @@
1
1
  import { NormalizedSchema } from '../schema';
2
- import { Tree } from '@nx/devkit';
3
- export declare function addProject(host: Tree, options: NormalizedSchema): void;
2
+ export declare function addProject(host: any, options: NormalizedSchema): void;
3
+ export declare function maybeJs(options: NormalizedSchema, path: string): string;
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addProject = void 0;
3
+ exports.maybeJs = exports.addProject = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
6
- const maybe_js_1 = require("../../../utils/maybe-js");
7
5
  function addProject(host, options) {
8
6
  const project = {
9
7
  root: options.appProjectRoot,
@@ -13,18 +11,22 @@ function addProject(host, options) {
13
11
  tags: options.parsedTags,
14
12
  };
15
13
  if (options.bundler === 'webpack') {
16
- if (!(0, has_webpack_plugin_1.hasWebpackPlugin)(host) || !options.addPlugin) {
17
- project.targets = {
18
- build: createBuildTarget(options),
19
- serve: createServeTarget(options),
20
- };
21
- }
14
+ project.targets = {
15
+ build: createBuildTarget(options),
16
+ serve: createServeTarget(options),
17
+ };
22
18
  }
23
19
  (0, devkit_1.addProjectConfiguration)(host, options.projectName, {
24
20
  ...project,
25
21
  });
26
22
  }
27
23
  exports.addProject = addProject;
24
+ function maybeJs(options, path) {
25
+ return options.js && (path.endsWith('.ts') || path.endsWith('.tsx'))
26
+ ? path.replace(/\.tsx?$/, '.js')
27
+ : path;
28
+ }
29
+ exports.maybeJs = maybeJs;
28
30
  function createBuildTarget(options) {
29
31
  return {
30
32
  executor: '@nx/webpack:webpack',
@@ -37,7 +39,7 @@ function createBuildTarget(options) {
37
39
  : options.projectName),
38
40
  index: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/index.html'),
39
41
  baseHref: '/',
40
- main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, `src/main.tsx`)),
42
+ main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, maybeJs(options, `src/main.tsx`)),
41
43
  tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
42
44
  assets: [
43
45
  (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/favicon.ico'),
@@ -49,6 +51,7 @@ function createBuildTarget(options) {
49
51
  (0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/styles.${options.style}`),
50
52
  ],
51
53
  scripts: [],
54
+ isolatedConfig: true,
52
55
  webpackConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'webpack.config.js'),
53
56
  },
54
57
  configurations: {
@@ -61,8 +64,8 @@ function createBuildTarget(options) {
61
64
  production: {
62
65
  fileReplacements: [
63
66
  {
64
- replace: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, `src/environments/environment.ts`)),
65
- with: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, `src/environments/environment.prod.ts`)),
67
+ replace: (0, devkit_1.joinPathFragments)(options.appProjectRoot, maybeJs(options, `src/environments/environment.ts`)),
68
+ with: (0, devkit_1.joinPathFragments)(options.appProjectRoot, maybeJs(options, `src/environments/environment.prod.ts`)),
66
69
  },
67
70
  ],
68
71
  optimization: true,
@@ -1,3 +1,3 @@
1
- import { Tree } from '@nx/devkit';
2
1
  import { NormalizedSchema } from '../schema';
2
+ import { Tree } from '@nx/devkit';
3
3
  export declare function addRouting(host: Tree, options: NormalizedSchema): import("@nx/devkit").GeneratorCallback;
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addRouting = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
6
4
  const ast_utils_1 = require("../../../utils/ast-utils");
7
5
  const versions_1 = require("../../../utils/versions");
8
- const maybe_js_1 = require("../../../utils/maybe-js");
6
+ const devkit_1 = require("@nx/devkit");
7
+ const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
9
8
  let tsModule;
10
9
  function addRouting(host, options) {
11
10
  if (!options.routing) {
@@ -14,7 +13,7 @@ function addRouting(host, options) {
14
13
  if (!tsModule) {
15
14
  tsModule = (0, ensure_typescript_1.ensureTypescript)();
16
15
  }
17
- const appPath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, `src/app/${options.fileName}.tsx`));
16
+ const appPath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, maybeJs(options, `src/app/${options.fileName}.tsx`));
18
17
  const appFileContent = host.read(appPath, 'utf-8');
19
18
  const appSource = tsModule.createSourceFile(appPath, appFileContent, tsModule.ScriptTarget.Latest, true);
20
19
  const changes = (0, devkit_1.applyChangesToString)(appFileContent, (0, ast_utils_1.addInitialRoutes)(appPath, appSource));
@@ -25,3 +24,8 @@ function addRouting(host, options) {
25
24
  return () => { };
26
25
  }
27
26
  exports.addRouting = addRouting;
27
+ function maybeJs(options, path) {
28
+ return options.js && (path.endsWith('.ts') || path.endsWith('.tsx'))
29
+ ? path.replace(/\.tsx?$/, '.js')
30
+ : path;
31
+ }
@@ -6,8 +6,6 @@ const js_1 = require("@nx/js");
6
6
  const path_1 = require("path");
7
7
  const create_ts_config_1 = require("../../../utils/create-ts-config");
8
8
  const get_in_source_vitest_tests_template_1 = require("../../../utils/get-in-source-vitest-tests-template");
9
- const maybe_js_1 = require("../../../utils/maybe-js");
10
- const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
11
9
  const get_app_tests_1 = require("./get-app-tests");
12
10
  function createApplicationFiles(host, options) {
13
11
  let styleSolutionSpecificAppFiles;
@@ -17,9 +15,6 @@ function createApplicationFiles(host, options) {
17
15
  else if (options.style === 'styled-jsx') {
18
16
  styleSolutionSpecificAppFiles = '../files/style-styled-jsx';
19
17
  }
20
- else if (options.style === 'tailwind') {
21
- styleSolutionSpecificAppFiles = '../files/style-tailwind';
22
- }
23
18
  else if (options.style === 'none') {
24
19
  styleSolutionSpecificAppFiles = '../files/style-none';
25
20
  }
@@ -43,12 +38,7 @@ function createApplicationFiles(host, options) {
43
38
  (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/base-vite'), options.appProjectRoot, templateVariables);
44
39
  }
45
40
  else if (options.bundler === 'webpack') {
46
- (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/base-webpack'), options.appProjectRoot, {
47
- ...templateVariables,
48
- webpackPluginOptions: (0, has_webpack_plugin_1.hasWebpackPlugin)(host)
49
- ? createNxWebpackPluginOptions(options)
50
- : null,
51
- });
41
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/base-webpack'), options.appProjectRoot, templateVariables);
52
42
  if (options.compiler === 'babel') {
53
43
  (0, devkit_1.writeJson)(host, `${options.appProjectRoot}/.babelrc`, {
54
44
  presets: [
@@ -122,22 +112,3 @@ function createApplicationFiles(host, options) {
122
112
  (0, create_ts_config_1.createTsConfig)(host, options.appProjectRoot, 'app', options, relativePathToRootTsConfig);
123
113
  }
124
114
  exports.createApplicationFiles = createApplicationFiles;
125
- function createNxWebpackPluginOptions(options) {
126
- return {
127
- target: 'web',
128
- compiler: options.compiler ?? 'babel',
129
- outputPath: (0, devkit_1.joinPathFragments)('dist', options.appProjectRoot != '.'
130
- ? options.appProjectRoot
131
- : options.projectName),
132
- index: './src/index.html',
133
- baseHref: '/',
134
- main: (0, maybe_js_1.maybeJs)(options, `./src/main.tsx`),
135
- tsConfig: './tsconfig.app.json',
136
- assets: ['./src/favicon.ico', './src/assets'],
137
- styles: options.styledModule || !options.hasStyles
138
- ? []
139
- : [
140
- `./src/styles.${options.style !== 'tailwind' ? options.style : 'css'}`,
141
- ],
142
- };
143
- }
@@ -4,18 +4,7 @@ exports.installCommonDependencies = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const versions_1 = require("../../../utils/versions");
6
6
  function installCommonDependencies(host, options) {
7
- if (options.skipPackageJson) {
8
- return () => { };
9
- }
10
- const dependencies = {};
11
- const devDependencies = {
12
- '@types/node': versions_1.typesNodeVersion,
13
- '@types/react': versions_1.typesReactVersion,
14
- '@types/react-dom': versions_1.typesReactDomVersion,
15
- };
16
- if (options.bundler !== 'vite') {
17
- dependencies['tslib'] = versions_1.tsLibVersion;
18
- }
7
+ const devDependencies = {};
19
8
  // Vite requires style preprocessors to be installed manually.
20
9
  // `@nx/webpack` installs them automatically for now.
21
10
  if (options.bundler === 'vite' || options.unitTestRunner === 'vitest') {
@@ -39,9 +28,6 @@ function installCommonDependencies(host, options) {
39
28
  devDependencies['@babel/core'] = versions_1.babelCoreVersion;
40
29
  }
41
30
  }
42
- if (options.unitTestRunner && options.unitTestRunner !== 'none') {
43
- devDependencies['@testing-library/react'] = versions_1.testingLibraryReactVersion;
44
- }
45
31
  return (0, devkit_1.addDependenciesToPackageJson)(host, {}, devDependencies);
46
32
  }
47
33
  exports.installCommonDependencies = installCommonDependencies;
@@ -26,46 +26,15 @@ async function normalizeOptions(host, options, callingGenerator = '@nx/react:app
26
26
  rootProject: options.rootProject,
27
27
  callingGenerator,
28
28
  });
29
- const nxJson = (0, devkit_1.readNxJson)(host);
30
- const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
31
- nxJson.useInferencePlugins !== false;
32
- options.addPlugin ??= addPlugin;
33
29
  options.rootProject = appProjectRoot === '.';
34
30
  options.projectNameAndRootFormat = projectNameAndRootFormat;
35
- let e2eWebServerTarget = 'serve';
36
- if (options.addPlugin) {
37
- if (nxJson.plugins) {
38
- for (const plugin of nxJson.plugins) {
39
- if (options.bundler === 'vite' &&
40
- typeof plugin === 'object' &&
41
- plugin.plugin === '@nx/vite/plugin' &&
42
- plugin.options.serveTargetName) {
43
- e2eWebServerTarget = plugin.options
44
- .serveTargetName;
45
- }
46
- else if (options.bundler === 'webpack' &&
47
- typeof plugin === 'object' &&
48
- plugin.plugin === '@nx/webpack/plugin' &&
49
- plugin.options.serveTargetName) {
50
- e2eWebServerTarget = plugin.options
51
- .serveTargetName;
52
- }
53
- }
54
- }
55
- }
56
- let e2ePort = options.devServerPort ?? 4200;
57
- if (nxJson.targetDefaults?.[e2eWebServerTarget] &&
58
- nxJson.targetDefaults?.[e2eWebServerTarget].options?.port) {
59
- e2ePort = nxJson.targetDefaults?.[e2eWebServerTarget].options?.port;
60
- }
61
31
  const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
62
32
  const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
63
- const e2eWebServerAddress = `http://localhost:${e2ePort}`;
64
33
  const parsedTags = options.tags
65
34
  ? options.tags.split(',').map((s) => s.trim())
66
35
  : [];
67
36
  const fileName = options.pascalCaseFiles ? 'App' : 'app';
68
- const styledModule = /^(css|scss|less|tailwind|none)$/.test(options.style)
37
+ const styledModule = /^(css|scss|less|none)$/.test(options.style)
69
38
  ? null
70
39
  : options.style;
71
40
  (0, assertion_1.assertValidStyle)(options.style);
@@ -79,9 +48,6 @@ async function normalizeOptions(host, options, callingGenerator = '@nx/react:app
79
48
  appProjectRoot,
80
49
  e2eProjectName,
81
50
  e2eProjectRoot,
82
- e2eWebServerAddress,
83
- e2eWebServerTarget,
84
- e2ePort,
85
51
  parsedTags,
86
52
  fileName,
87
53
  styledModule,
@@ -14,7 +14,6 @@ function setDefaults(host, options) {
14
14
  nxJson.generators['@nx/react'] = nxJson.generators['@nx/react'] || {};
15
15
  const prev = { ...nxJson.generators['@nx/react'] };
16
16
  const appDefaults = {
17
- babel: true,
18
17
  style: options.style,
19
18
  linter: options.linter,
20
19
  bundler: options.bundler,
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateSpecConfig = void 0;
4
- const maybe_js_1 = require("../../../utils/maybe-js");
5
4
  const jest_utils_1 = require("../../../utils/jest-utils");
6
5
  const devkit_1 = require("@nx/devkit");
7
6
  function updateSpecConfig(host, options) {
@@ -9,20 +8,21 @@ function updateSpecConfig(host, options) {
9
8
  return;
10
9
  }
11
10
  (0, devkit_1.updateJson)(host, `${options.appProjectRoot}/tsconfig.spec.json`, (json) => {
12
- const compilerOptions = json.compilerOptions ?? {};
13
- const types = compilerOptions.types ?? [];
11
+ json.types = json.types || [];
14
12
  if (options.style === 'styled-jsx') {
15
- types.push('@nx/react/typings/styled-jsx.d.ts');
13
+ json.types.push('@nx/react/typings/styled-jsx.d.ts');
16
14
  }
17
- types.push('@nx/react/typings/cssmodule.d.ts', '@nx/react/typings/image.d.ts');
18
- compilerOptions.types = types;
19
- json.compilerOptions = compilerOptions;
15
+ json.types = [
16
+ ...json.types,
17
+ '@nx/react/typings/cssmodule.d.ts',
18
+ '@nx/react/typings/image.d.ts',
19
+ ];
20
20
  return json;
21
21
  });
22
22
  if (options.unitTestRunner !== 'jest') {
23
23
  return;
24
24
  }
25
- const configPath = (0, maybe_js_1.maybeJs)(options, `${options.appProjectRoot}/jest.config.ts`);
25
+ const configPath = `${options.appProjectRoot}/jest.config.${options.js ? 'js' : 'ts'}`;
26
26
  const originalContent = host.read(configPath, 'utf-8');
27
27
  const content = (0, jest_utils_1.updateJestConfigContent)(originalContent);
28
28
  host.write(configPath, content);
@@ -28,7 +28,6 @@ export interface Schema {
28
28
  rootProject?: boolean;
29
29
  bundler?: 'webpack' | 'vite' | 'rspack';
30
30
  minimal?: boolean;
31
- addPlugin?: boolean;
32
31
  }
33
32
 
34
33
  export interface NormalizedSchema<T extends Schema = Schema> extends T {
@@ -36,13 +35,9 @@ export interface NormalizedSchema<T extends Schema = Schema> extends T {
36
35
  appProjectRoot: string;
37
36
  e2eProjectName: string;
38
37
  e2eProjectRoot: string;
39
- e2eWebServerAddress: string;
40
- e2eWebServerTarget: string;
41
- e2ePort: number;
42
38
  parsedTags: string[];
43
39
  fileName: string;
44
40
  styledModule: null | SupportedStyles;
45
41
  hasStyles: boolean;
46
42
  unitTestRunner: 'jest' | 'vitest' | 'none';
47
- addPlugin?: boolean;
48
43
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://json-schema.org/schema",
2
+ "$schema": "http://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxReactApp",
5
5
  "title": "Create a React Application",
@@ -56,15 +56,11 @@
56
56
  },
57
57
  {
58
58
  "value": "scss",
59
- "label": "SASS(.scss) [ https://sass-lang.com ]"
59
+ "label": "SASS(.scss) [ http://sass-lang.com ]"
60
60
  },
61
61
  {
62
62
  "value": "less",
63
- "label": "LESS [ https://lesscss.org ]"
64
- },
65
- {
66
- "value": "tailwind",
67
- "label": "tailwind [ https://tailwindcss.com/ ]"
63
+ "label": "LESS [ http://lesscss.org ]"
68
64
  },
69
65
  {
70
66
  "value": "styled-components",
@@ -32,30 +32,13 @@ const Styled<%= className %> = styled.div`
32
32
  color: pink;
33
33
  `;
34
34
  <% }%>
35
- <% if(!isNextPage) { %>
36
- <% if (classComponent) { %>
37
- export class <%= className %> extends Component<<%= className %>Props> {
38
- override render() {
39
- return (
40
- <<%= wrapper %><%- extras %>>
41
- <%= styledModule === 'styled-jsx' ? `<style jsx>{\`div { color: pink; }\`}</style>` : `` %>
42
- <p>Welcome to <%= className %>!</p>
43
- <% if (routing) { %>
44
- <ul>
45
- <li><Link to="/"><%= name %> root</Link></li>
46
- </ul>
47
- <Route path="/" element={<div>This is the <%= name %> root route.</div>} />
48
- <% } %>
49
- </<%= wrapper %>>
50
- );
51
- }
52
- }
53
- <% } else { %>
54
- export function <%= className %>(props: <%= className %>Props) {
35
+ <% if (classComponent) { %>
36
+ export class <%= className %> extends Component<<%= className %>Props> {
37
+ override render() {
55
38
  return (
56
39
  <<%= wrapper %><%- extras %>>
57
- <% if (styledModule === 'styled-jsx') { %><style jsx>{`div { color: pink; }`}</style><% } %>
58
- <h1>Welcome to <%= className %>!</h1>
40
+ <%= styledModule === 'styled-jsx' ? `<style jsx>{\`div { color: pink; }\`}</style>` : `` %>
41
+ <p>Welcome to <%= className %>!</p>
59
42
  <% if (routing) { %>
60
43
  <ul>
61
44
  <li><Link to="/"><%= name %> root</Link></li>
@@ -65,24 +48,24 @@ const Styled<%= className %> = styled.div`
65
48
  </<%= wrapper %>>
66
49
  );
67
50
  }
68
- <% } %>
69
-
70
- export default <%= className %>;
51
+ }
71
52
  <% } else { %>
72
- export default function <%= className %>(props: <%= className %>Props) {
73
- return (
74
- <<%= wrapper %><%- extras %>>
75
- <% if (styledModule === 'styled-jsx') { %><style jsx>{`div { color: pink; }`}</style><% } %>
76
- <h1>Welcome to <%= className %>!</h1>
77
- <% if (routing) { %>
78
- <ul>
79
- <li><Link to="/"><%= name %> root</Link></li>
80
- </ul>
81
- <Route path="/" element={<div>This is the <%= name %> root route.</div>} />
82
- <% } %>
83
- </<%= wrapper %>>
84
- );
85
- };
53
+ export function <%= className %>(props: <%= className %>Props) {
54
+ return (
55
+ <<%= wrapper %><%- extras %>>
56
+ <% if (styledModule === 'styled-jsx') { %><style jsx>{`div { color: pink; }`}</style><% } %>
57
+ <h1>Welcome to <%= className %>!</h1>
58
+ <% if (routing) { %>
59
+ <ul>
60
+ <li><Link to="/"><%= name %> root</Link></li>
61
+ </ul>
62
+ <Route path="/" element={<div>This is the <%= name %> root route.</div>} />
63
+ <% } %>
64
+ </<%= wrapper %>>
65
+ );
66
+ };
86
67
  <% } %>
87
68
 
69
+ export default <%= className %>;
70
+
88
71
  <% if (inSourceTests === true) { %> <%- inSourceVitestTests %> <% } %>
@@ -22,7 +22,7 @@ async function normalizeOptions(tree, options) {
22
22
  });
23
23
  const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
24
24
  const { className } = (0, devkit_1.names)(name);
25
- const { sourceRoot: projectSourceRoot, root: projectRoot, projectType, } = project;
25
+ const { sourceRoot: projectSourceRoot, projectType } = project;
26
26
  const styledModule = /^(css|scss|less|none)$/.test(options.style)
27
27
  ? null
28
28
  : options.style;
@@ -33,8 +33,6 @@ async function normalizeOptions(tree, options) {
33
33
  options.routing = options.routing ?? false;
34
34
  options.globalCss = options.globalCss ?? false;
35
35
  options.inSourceTests = options.inSourceTests ?? false;
36
- //TODO (nicholas): Remove when Next page generator is removed
37
- options.isNextPage = options.isNextPage ?? false;
38
36
  return {
39
37
  ...options,
40
38
  projectName,
@@ -44,7 +42,7 @@ async function normalizeOptions(tree, options) {
44
42
  className,
45
43
  fileName,
46
44
  filePath,
47
- projectSourceRoot: projectSourceRoot ?? projectRoot,
45
+ projectSourceRoot,
48
46
  };
49
47
  }
50
48
  exports.normalizeOptions = normalizeOptions;
@@ -3,7 +3,7 @@ import { SupportedStyles } from '../../../typings/style';
3
3
  export interface Schema {
4
4
  name: string;
5
5
  /**
6
- * @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19.
6
+ * @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v18.
7
7
  */
8
8
  project?: string;
9
9
  style: SupportedStyles;
@@ -11,18 +11,18 @@ export interface Schema {
11
11
  directory?: string;
12
12
  export?: boolean;
13
13
  /**
14
- * @deprecated Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19.
14
+ * @deprecated Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v18.
15
15
  */
16
16
  pascalCaseFiles?: boolean;
17
17
  /**
18
- * @deprecated Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19.
18
+ * @deprecated Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v18.
19
19
  */
20
20
  pascalCaseDirectory?: boolean;
21
21
  classComponent?: boolean;
22
22
  routing?: boolean;
23
23
  js?: boolean;
24
24
  /**
25
- * @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
25
+ * @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v18.
26
26
  */
27
27
  flat?: boolean;
28
28
  globalCss?: boolean;
@@ -33,8 +33,6 @@ export interface Schema {
33
33
  // Used by other wrapping generators to preserve previous behavior
34
34
  // e.g. @nx/next:component
35
35
  derivedDirectory?: string;
36
- // Used by Next.js to determine how React should generate the page
37
- isNextPage?: boolean;
38
36
  }
39
37
 
40
38
  export interface NormalizedSchema extends Schema {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://json-schema.org/schema",
2
+ "$schema": "http://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxReactComponent",
5
5
  "title": "Create a React Component",
@@ -13,7 +13,7 @@
13
13
  "$default": {
14
14
  "$source": "projectName"
15
15
  },
16
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
16
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v18."
17
17
  },
18
18
  "name": {
19
19
  "type": "string",
@@ -40,11 +40,11 @@
40
40
  },
41
41
  {
42
42
  "value": "scss",
43
- "label": "SASS(.scss) [ https://sass-lang.com ]"
43
+ "label": "SASS(.scss) [ http://sass-lang.com ]"
44
44
  },
45
45
  {
46
46
  "value": "less",
47
- "label": "LESS [ https://lesscss.org ]"
47
+ "label": "LESS [ http://lesscss.org ]"
48
48
  },
49
49
  {
50
50
  "value": "styled-components",
@@ -91,7 +91,7 @@
91
91
  "type": "boolean",
92
92
  "description": "Create component at the source root rather than its own directory.",
93
93
  "default": false,
94
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19."
94
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v18."
95
95
  },
96
96
  "export": {
97
97
  "type": "boolean",
@@ -105,14 +105,14 @@
105
105
  "description": "Use pascal case component file name (e.g. `App.tsx`).",
106
106
  "alias": "P",
107
107
  "default": false,
108
- "x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
108
+ "x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v18."
109
109
  },
110
110
  "pascalCaseDirectory": {
111
111
  "type": "boolean",
112
112
  "description": "Use pascal case directory name (e.g. `App/App.tsx`).",
113
113
  "alias": "R",
114
114
  "default": false,
115
- "x-deprecated": "Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
115
+ "x-deprecated": "Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v18."
116
116
  },
117
117
  "classComponent": {
118
118
  "type": "boolean",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://json-schema.org/schema",
2
+ "$schema": "http://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxReactComponentCypressSpec",
5
5
  "title": "Create component Cypress spec",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://json-schema.org/schema",
2
+ "$schema": "http://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxReactComponentStory",
5
5
  "title": "Create component story",