@nx/react 17.0.5 → 17.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +4 -9
  3. package/generators.json +1 -1
  4. package/index.d.ts +0 -1
  5. package/index.js +1 -3
  6. package/migrations.json +0 -21
  7. package/package.json +7 -7
  8. package/plugins/component-testing/index.js +24 -52
  9. package/plugins/component-testing/webpack-fallback.js +1 -1
  10. package/plugins/storybook/index.js +2 -6
  11. package/plugins/storybook/merge-plugins.d.ts +1 -1
  12. package/plugins/webpack.d.ts +3 -1
  13. package/plugins/webpack.js +11 -3
  14. package/plugins/with-react.d.ts +4 -2
  15. package/plugins/with-react.js +58 -2
  16. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +0 -13
  17. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +58 -173
  18. package/src/executors/module-federation-dev-server/schema.json +1 -13
  19. package/src/generators/application/application.js +18 -41
  20. package/src/generators/application/files/base-vite/index.html__tmpl__ +1 -1
  21. package/src/generators/application/files/base-webpack/src/environments/environment.prod.ts__tmpl__ +3 -0
  22. package/src/generators/application/files/base-webpack/src/environments/environment.ts__tmpl__ +6 -0
  23. package/src/generators/application/files/base-webpack/src/index.html +2 -0
  24. package/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +5 -46
  25. package/src/generators/application/files/nx-welcome/src/app/nx-welcome.tsx +13 -54
  26. package/src/generators/application/lib/add-e2e.js +7 -25
  27. package/src/generators/application/lib/add-jest.js +2 -2
  28. package/src/generators/application/lib/add-project.d.ts +2 -2
  29. package/src/generators/application/lib/add-project.js +15 -12
  30. package/src/generators/application/lib/add-routing.d.ts +1 -1
  31. package/src/generators/application/lib/add-routing.js +8 -4
  32. package/src/generators/application/lib/create-application-files.js +1 -30
  33. package/src/generators/application/lib/install-common-dependencies.js +1 -15
  34. package/src/generators/application/lib/normalize-options.js +1 -35
  35. package/src/generators/application/lib/set-defaults.js +0 -1
  36. package/src/generators/application/lib/update-jest-config.js +8 -8
  37. package/src/generators/application/schema.d.ts +0 -5
  38. package/src/generators/application/schema.json +3 -7
  39. package/src/generators/component/files/__fileName__.tsx__tmpl__ +22 -39
  40. package/src/generators/component/lib/normalize-options.js +2 -4
  41. package/src/generators/component/schema.d.ts +4 -6
  42. package/src/generators/component/schema.json +7 -7
  43. package/src/generators/component-cypress-spec/schema.json +1 -1
  44. package/src/generators/component-story/schema.json +1 -1
  45. package/src/generators/component-test/schema.json +1 -1
  46. package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts +1 -2
  47. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +7 -18
  48. package/src/generators/cypress-component-configuration/lib/add-files.js +6 -1
  49. package/src/generators/cypress-component-configuration/schema.d.ts +0 -1
  50. package/src/generators/federate-module/federate-module.js +2 -2
  51. package/src/generators/federate-module/schema.d.ts +1 -1
  52. package/src/generators/federate-module/schema.json +3 -4
  53. package/src/generators/hook/files/__fileName__.ts__tmpl__ +15 -15
  54. package/src/generators/hook/schema.d.ts +4 -4
  55. package/src/generators/hook/schema.json +5 -5
  56. package/src/generators/host/files/module-federation/module-federation.config.js__tmpl__ +2 -17
  57. package/src/generators/host/files/module-federation/src/main.ts__tmpl__ +1 -0
  58. package/src/generators/host/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +2 -5
  59. package/src/generators/host/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +2 -5
  60. package/src/generators/host/files/module-federation-ts/module-federation.config.ts__tmpl__ +2 -17
  61. package/src/generators/host/files/module-federation-ts/src/main.ts__tmpl__ +1 -0
  62. package/src/generators/host/files/module-federation-ts/webpack.config.prod.ts__tmpl__ +1 -2
  63. package/src/generators/host/files/module-federation-ts/webpack.config.ts__tmpl__ +2 -2
  64. package/src/generators/host/host.js +1 -15
  65. package/src/generators/host/lib/add-module-federation-files.d.ts +1 -2
  66. package/src/generators/host/lib/add-module-federation-files.js +11 -24
  67. package/src/generators/host/lib/setup-ssr-for-host.js +0 -1
  68. package/src/generators/host/lib/update-module-federation-e2e-project.js +5 -7
  69. package/src/generators/host/schema.d.ts +2 -5
  70. package/src/generators/host/schema.json +6 -16
  71. package/src/generators/init/init.d.ts +1 -1
  72. package/src/generators/init/init.js +49 -10
  73. package/src/generators/init/schema.d.ts +6 -1
  74. package/src/generators/init/schema.json +22 -5
  75. package/src/generators/library/lib/add-linting.js +2 -2
  76. package/src/generators/library/lib/add-rollup-build-target.d.ts +1 -2
  77. package/src/generators/library/lib/add-rollup-build-target.js +8 -16
  78. package/src/generators/library/lib/install-common-dependencies.js +5 -13
  79. package/src/generators/library/lib/maybe-js.d.ts +2 -0
  80. package/src/generators/library/lib/normalize-options.js +5 -34
  81. package/src/generators/library/lib/update-app-routes.js +1 -1
  82. package/src/generators/library/library.js +6 -17
  83. package/src/generators/library/schema.d.ts +0 -1
  84. package/src/generators/library/schema.json +3 -3
  85. package/src/generators/redux/schema.d.ts +1 -1
  86. package/src/generators/redux/schema.json +2 -2
  87. package/src/generators/remote/files/module-federation/module-federation.config.js__tmpl__ +1 -4
  88. package/src/generators/remote/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +1 -1
  89. package/src/generators/remote/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +1 -1
  90. package/src/generators/remote/files/module-federation-ts/module-federation.config.ts__tmpl__ +1 -4
  91. package/src/generators/remote/lib/setup-ssr-for-remote.js +1 -5
  92. package/src/generators/remote/lib/setup-tspath-for-remote.js +1 -2
  93. package/src/generators/remote/lib/update-host-with-remote.js +1 -10
  94. package/src/generators/remote/remote.js +2 -22
  95. package/src/generators/remote/schema.d.ts +2 -3
  96. package/src/generators/remote/schema.json +6 -17
  97. package/src/generators/setup-ssr/schema.json +1 -1
  98. package/src/generators/setup-ssr/setup-ssr.js +7 -23
  99. package/src/generators/setup-tailwind/schema.json +1 -1
  100. package/src/generators/stories/schema.json +1 -1
  101. package/src/generators/stories/stories.js +5 -17
  102. package/src/generators/storybook-configuration/configuration.d.ts +0 -2
  103. package/src/generators/storybook-configuration/configuration.js +15 -37
  104. package/src/generators/storybook-configuration/schema.d.ts +1 -2
  105. package/src/generators/storybook-configuration/schema.json +7 -7
  106. package/src/module-federation/ast-utils.js +1 -1
  107. package/src/module-federation/utils.js +1 -8
  108. package/src/module-federation/with-module-federation-ssr.js +0 -3
  109. package/src/module-federation/with-module-federation.d.ts +3 -3
  110. package/src/module-federation/with-module-federation.js +4 -14
  111. package/src/rules/update-module-federation-project.d.ts +0 -2
  112. package/src/rules/update-module-federation-project.js +3 -12
  113. package/src/utils/assertion.js +0 -1
  114. package/src/utils/ct-utils.d.ts +1 -6
  115. package/src/utils/ct-utils.js +9 -39
  116. package/src/utils/get-in-source-vitest-tests-template.js +1 -1
  117. package/src/utils/versions.d.ts +1 -1
  118. package/src/utils/versions.js +1 -1
  119. package/typings/style.d.ts +0 -1
  120. package/mf/dynamic-federation.d.ts +0 -4
  121. package/mf/dynamic-federation.js +0 -75
  122. package/mf/index.d.ts +0 -1
  123. package/mf/index.js +0 -7
  124. package/plugins/nx-react-webpack-plugin/lib/apply-react-config.d.ts +0 -4
  125. package/plugins/nx-react-webpack-plugin/lib/apply-react-config.js +0 -86
  126. package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.d.ts +0 -8
  127. package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.js +0 -13
  128. package/src/generators/application/files/style-tailwind/src/app/__fileName__.tsx__tmpl__ +0 -33
  129. package/src/generators/application/files/style-tailwind/src/styles.css +0 -1
  130. package/src/generators/host/files/common/src/main.js__tmpl__ +0 -10
  131. package/src/generators/host/files/common/tsconfig.lint.json__tmpl__ +0 -19
  132. package/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ +0 -41
  133. package/src/generators/host/files/common-ts/src/main.ts__tmpl__ +0 -10
  134. package/src/generators/remote/files/module-federation-ssr-ts/tsconfig.lint.json__tmpl__ +0 -19
  135. package/src/generators/remote/files/module-federation-ts/tsconfig.lint.json__tmpl__ +0 -19
  136. package/src/generators/remote/lib/add-remote-to-dynamic-host.d.ts +0 -2
  137. package/src/generators/remote/lib/add-remote-to-dynamic-host.js +0 -11
  138. package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.d.ts +0 -2
  139. package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.js +0 -26
  140. package/src/migrations/update-18-1-1/fix-target-defaults-inputs.d.ts +0 -2
  141. package/src/migrations/update-18-1-1/fix-target-defaults-inputs.js +0 -53
  142. package/src/utils/add-mf-env-to-inputs.d.ts +0 -2
  143. package/src/utils/add-mf-env-to-inputs.js +0 -27
  144. package/src/utils/has-vite-plugin.d.ts +0 -2
  145. package/src/utils/has-vite-plugin.js +0 -11
  146. package/src/utils/has-webpack-plugin.d.ts +0 -2
  147. package/src/utils/has-webpack-plugin.js +0 -11
  148. package/src/utils/maybe-js.d.ts +0 -3
  149. /package/src/generators/host/files/common/src/app/{__fileName__.js__tmpl__ → __fileName__.tsx__tmpl__} +0 -0
  150. /package/src/{utils → generators/library/lib}/maybe-js.js +0 -0
  151. /package/src/generators/remote/files/{common/src/main.js__tmpl__ → module-federation/src/main.ts__tmpl__} +0 -0
  152. /package/src/generators/remote/files/{common/src/remote-entry.js__tmpl__ → module-federation/src/remote-entry.ts__tmpl__} +0 -0
  153. /package/src/generators/remote/files/{common-ts → module-federation-ts}/src/main.ts__tmpl__ +0 -0
  154. /package/src/generators/remote/files/{common-ts → module-federation-ts}/src/remote-entry.ts__tmpl__ +0 -0
@@ -274,21 +274,12 @@ export function NxWelcome({ title }: { title: string }) {
274
274
  .button-pill:hover {
275
275
  color: rgba(255, 255, 255, 1) !important;
276
276
  }
277
- #nx-console:hover {
277
+ .nx-console:hover {
278
278
  background-color: rgba(0, 122, 204, 1);
279
279
  }
280
- #nx-console svg {
280
+ .nx-console svg {
281
281
  color: rgba(0, 122, 204, 1);
282
282
  }
283
- #nx-console-jetbrains {
284
- margin-top: 2rem;
285
- }
286
- #nx-console-jetbrains:hover {
287
- background-color: rgba(255, 49, 140, 1);
288
- }
289
- #nx-console-jetbrains svg {
290
- color: rgba(255, 49, 140, 1);
291
- }
292
283
  #nx-repo:hover {
293
284
  background-color: rgba(24, 23, 23, 1);
294
285
  }
@@ -653,8 +644,7 @@ export function NxWelcome({ title }: { title: string }) {
653
644
  </div>
654
645
  <div id="other-links">
655
646
  <a
656
- id="nx-console"
657
- className="button-pill rounded shadow"
647
+ className="button-pill nx-console rounded shadow"
658
648
  href="https://marketplace.visualstudio.com/items?itemName=nrwl.angular-console&utm_source=nx-project"
659
649
  target="_blank"
660
650
  rel="noreferrer"
@@ -670,35 +660,23 @@ export function NxWelcome({ title }: { title: string }) {
670
660
  </svg>
671
661
  <span>
672
662
  Install Nx Console for VSCode
673
- <span>The official VSCode extension for Nx.</span>
663
+ <span>The official VSCode plugin for Nx.</span>
674
664
  </span>
675
665
  </a>
676
666
  <a
677
- id="nx-console-jetbrains"
678
- className="button-pill rounded shadow"
667
+ className="button-pill nx-console rounded shadow"
679
668
  href="https://plugins.jetbrains.com/plugin/21060-nx-console"
680
669
  target="_blank"
681
670
  rel="noreferrer"
682
671
  >
683
672
  <svg
684
- height="48"
685
- width="48"
686
- viewBox="20 20 60 60"
673
+ fill="currentColor"
674
+ role="img"
675
+ viewBox="0 0 24 24"
687
676
  xmlns="http://www.w3.org/2000/svg"
688
677
  >
689
- <path d="m22.5 22.5h60v60h-60z" />
690
- <g fill="#fff">
691
- <path d="m29.03 71.25h22.5v3.75h-22.5z" />
692
- <path d="m28.09 38 1.67-1.58a1.88 1.88 0 0 0 1.47.87c.64 0 1.06-.44 1.06-1.31v-5.98h2.58v6a3.48 3.48 0 0 1 -.87 2.6 3.56 3.56 0 0 1 -2.57.95 3.84 3.84 0 0 1 -3.34-1.55z" />
693
- <path d="m36 30h7.53v2.19h-5v1.44h4.49v2h-4.42v1.49h5v2.21h-7.6z" />
694
- <path d="m47.23 32.29h-2.8v-2.29h8.21v2.27h-2.81v7.1h-2.6z" />
695
- <path d="m29.13 43.08h4.42a3.53 3.53 0 0 1 2.55.83 2.09 2.09 0 0 1 .6 1.53 2.16 2.16 0 0 1 -1.44 2.09 2.27 2.27 0 0 1 1.86 2.29c0 1.61-1.31 2.59-3.55 2.59h-4.44zm5 2.89c0-.52-.42-.8-1.18-.8h-1.29v1.64h1.24c.79 0 1.25-.26 1.25-.81zm-.9 2.66h-1.57v1.73h1.62c.8 0 1.24-.31 1.24-.86 0-.5-.4-.87-1.27-.87z" />
696
- <path d="m38 43.08h4.1a4.19 4.19 0 0 1 3 1 2.93 2.93 0 0 1 .9 2.19 3 3 0 0 1 -1.93 2.89l2.24 3.27h-3l-1.88-2.84h-.87v2.84h-2.56zm4 4.5c.87 0 1.39-.43 1.39-1.11 0-.75-.54-1.12-1.4-1.12h-1.44v2.26z" />
697
- <path d="m49.59 43h2.5l4 9.44h-2.79l-.67-1.69h-3.63l-.67 1.69h-2.71zm2.27 5.73-1-2.65-1.06 2.65z" />
698
- <path d="m56.46 43.05h2.6v9.37h-2.6z" />
699
- <path d="m60.06 43.05h2.42l3.37 5v-5h2.57v9.37h-2.26l-3.53-5.14v5.14h-2.57z" />
700
- <path d="m68.86 51 1.45-1.73a4.84 4.84 0 0 0 3 1.13c.71 0 1.08-.24 1.08-.65 0-.4-.31-.6-1.59-.91-2-.46-3.53-1-3.53-2.93 0-1.74 1.37-3 3.62-3a5.89 5.89 0 0 1 3.86 1.25l-1.26 1.84a4.63 4.63 0 0 0 -2.62-.92c-.63 0-.94.25-.94.6 0 .42.32.61 1.63.91 2.14.46 3.44 1.16 3.44 2.91 0 1.91-1.51 3-3.79 3a6.58 6.58 0 0 1 -4.35-1.5z" />
701
- </g>
678
+ <title>IntelliJ</title>
679
+ <path d="M0 0v24h24V0zm3.723 3.111h5v1.834h-1.39v6.277h1.39v1.834h-5v-1.834h1.444V4.945H3.723zm11.055 0H17v6.5c0 .612-.055 1.111-.222 1.556-.167.444-.39.777-.723 1.11-.277.279-.666.557-1.11.668a3.933 3.933 0 0 1-1.445.278c-.778 0-1.444-.167-1.944-.445a4.81 4.81 0 0 1-1.279-1.056l1.39-1.555c.277.334.555.555.833.722.277.167.611.278.945.278.389 0 .721-.111 1-.389.221-.278.333-.667.333-1.278zM2.222 19.5h9V21h-9z"></path>
702
680
  </svg>
703
681
  <span>
704
682
  Install Nx Console for JetBrains
@@ -727,7 +705,7 @@ export function NxWelcome({ title }: { title: string }) {
727
705
  />
728
706
  </svg>
729
707
  <h2>
730
- Nx Cloud
708
+ NxCloud
731
709
  <span>Enable faster CI & better DX</span>
732
710
  </h2>
733
711
  </div>
@@ -735,7 +713,7 @@ export function NxWelcome({ title }: { title: string }) {
735
713
  You can activate distributed tasks executions and caching by
736
714
  running:
737
715
  </p>
738
- <pre>nx connect</pre>
716
+ <pre>nx connect-to-nx-cloud</pre>
739
717
  <a
740
718
  href="https://nx.app/?utm_source=nx-project"
741
719
  target="_blank"
@@ -792,28 +770,9 @@ export function NxWelcome({ title }: { title: string }) {
792
770
  <span># Generate UI lib</span>
793
771
  nx g @nx/react:lib ui
794
772
  <span># Add a component</span>
795
- nx g @nx/react:component ui/src/lib/button
773
+ nx g @nx/react:component button --project ui
796
774
  </pre>
797
775
  </details>
798
- <details>
799
- <summary>
800
- <svg
801
- fill="none"
802
- stroke="currentColor"
803
- viewBox="0 0 24 24"
804
- xmlns="http://www.w3.org/2000/svg"
805
- >
806
- <path
807
- strokeLinecap="round"
808
- strokeLinejoin="round"
809
- strokeWidth="2"
810
- d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
811
- />
812
- </svg>
813
- View project details
814
- </summary>
815
- <pre>nx show project {title} --web</pre>
816
- </details>
817
776
  <details>
818
777
  <summary>
819
778
  <svg
@@ -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 %> <% } %>