@nx/react 0.0.0-pr-28808-a9a1b13 → 0.0.0-pr-29047-57d3073

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 (59) hide show
  1. package/migrations.json +27 -0
  2. package/module-federation.d.ts +6 -4
  3. package/module-federation.js +16 -7
  4. package/package.json +6 -7
  5. package/src/generators/application/application.js +13 -25
  6. package/src/generators/application/files/base-rspack/rspack.config.js__tmpl__ +53 -0
  7. package/src/generators/application/files/base-rspack/tsconfig.app.json__tmpl__ +4 -21
  8. package/src/generators/application/files/base-vite/tsconfig.app.json__tmpl__ +2 -19
  9. package/src/generators/application/files/base-webpack/tsconfig.app.json__tmpl__ +3 -20
  10. package/src/generators/application/files/style-css-module/src/app/__fileName__.tsx__tmpl__ +2 -2
  11. package/src/generators/application/lib/add-e2e.d.ts +1 -1
  12. package/src/generators/application/lib/add-e2e.js +15 -41
  13. package/src/generators/application/lib/add-jest.js +0 -1
  14. package/src/generators/application/lib/add-project.js +68 -15
  15. package/src/generators/application/lib/create-application-files.js +28 -3
  16. package/src/generators/application/lib/normalize-options.js +0 -2
  17. package/src/generators/application/lib/update-jest-config.js +0 -5
  18. package/src/generators/application/schema.d.ts +0 -5
  19. package/src/generators/application/schema.json +15 -19
  20. package/src/generators/component/component.js +1 -3
  21. package/src/generators/component/lib/normalize-options.js +1 -2
  22. package/src/generators/component/schema.d.ts +0 -1
  23. package/src/generators/host/files/webpack-module-federation/webpack.config.js__tmpl__ +1 -1
  24. package/src/generators/host/files/webpack-module-federation/webpack.config.prod.js__tmpl__ +1 -1
  25. package/src/generators/host/files/webpack-module-federation-ssr/webpack.server.config.js__tmpl__ +1 -1
  26. package/src/generators/host/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +1 -1
  27. package/src/generators/host/files/webpack-module-federation-ts/webpack.config.prod.ts__tmpl__ +1 -1
  28. package/src/generators/host/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +1 -1
  29. package/src/generators/host/host.js +2 -3
  30. package/src/generators/init/init.js +2 -0
  31. package/src/generators/library/files/common/package.json__tmpl__ +4 -0
  32. package/src/generators/library/files/vite/package.json__tmpl__ +12 -0
  33. package/src/generators/library/lib/create-files.d.ts +1 -1
  34. package/src/generators/library/lib/create-files.js +2 -22
  35. package/src/generators/library/lib/normalize-options.js +0 -22
  36. package/src/generators/library/library.js +16 -34
  37. package/src/generators/library/schema.d.ts +0 -1
  38. package/src/generators/library/schema.json +6 -6
  39. package/src/generators/remote/files/webpack-module-federation/webpack.config.js__tmpl__ +1 -1
  40. package/src/generators/remote/files/webpack-module-federation-ssr/webpack.server.config.js__tmpl__ +1 -1
  41. package/src/generators/remote/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +1 -1
  42. package/src/generators/remote/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +1 -1
  43. package/src/generators/remote/remote.js +2 -1
  44. package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.d.ts +2 -0
  45. package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.js +35 -0
  46. package/src/rules/update-module-federation-project.js +6 -10
  47. package/src/utils/create-ts-config.js +7 -57
  48. package/src/utils/has-rspack-plugin.d.ts +2 -0
  49. package/src/utils/has-rspack-plugin.js +10 -0
  50. package/src/utils/versions.d.ts +3 -2
  51. package/src/utils/versions.js +5 -3
  52. package/src/generators/host/lib/update-module-federation-tsconfig.d.ts +0 -3
  53. package/src/generators/host/lib/update-module-federation-tsconfig.js +0 -39
  54. package/src/module-federation/utils.d.ts +0 -12
  55. package/src/module-federation/utils.js +0 -75
  56. package/src/module-federation/with-module-federation-ssr.d.ts +0 -2
  57. package/src/module-federation/with-module-federation-ssr.js +0 -50
  58. package/src/module-federation/with-module-federation.d.ts +0 -7
  59. package/src/module-federation/with-module-federation.js +0 -63
package/migrations.json CHANGED
@@ -35,6 +35,12 @@
35
35
  "version": "20.2.0-beta.2",
36
36
  "description": "Update the ModuleFederationConfig import use @nx/module-federation.",
37
37
  "factory": "./src/migrations/update-20-2-0/migrate-mf-imports-to-new-package"
38
+ },
39
+ "update-20-2-0-update-with-module-federation-import": {
40
+ "cli": "nx",
41
+ "version": "20.2.0-beta.2",
42
+ "description": "Update the withModuleFederation import use @nx/module-federation/webpack.",
43
+ "factory": "./src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package"
38
44
  }
39
45
  },
40
46
  "packageJsonUpdates": {
@@ -158,6 +164,27 @@
158
164
  "alwaysAddToPackageJson": false
159
165
  }
160
166
  }
167
+ },
168
+ "20.2.0": {
169
+ "version": "20.2.0-beta.3",
170
+ "packages": {
171
+ "@module-federation/enhanced": {
172
+ "version": "0.7.6",
173
+ "alwaysAddToPackageJson": false
174
+ },
175
+ "@module-federation/runtime": {
176
+ "version": "0.7.6",
177
+ "alwaysAddToPackageJson": false
178
+ },
179
+ "@module-federation/sdk": {
180
+ "version": "0.7.6",
181
+ "alwaysAddToPackageJson": false
182
+ },
183
+ "@module-federation/node": {
184
+ "version": "2.6.11",
185
+ "alwaysAddToPackageJson": false
186
+ }
187
+ }
161
188
  }
162
189
  }
163
190
  }
@@ -1,4 +1,6 @@
1
- import { withModuleFederation } from './src/module-federation/with-module-federation';
2
- import { withModuleFederationForSSR } from './src/module-federation/with-module-federation-ssr';
3
- export { withModuleFederation };
4
- export { withModuleFederationForSSR };
1
+ import { withModuleFederation } from '@nx/module-federation/webpack';
2
+ import { withModuleFederationForSSR } from '@nx/module-federation/webpack';
3
+ /**
4
+ * @deprecated Use `@nx/module-federation/webpack` instead. This will be removed in Nx v22.
5
+ */
6
+ export { withModuleFederation, withModuleFederationForSSR };
@@ -1,12 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withModuleFederationForSSR = exports.withModuleFederation = void 0;
4
- const with_module_federation_1 = require("./src/module-federation/with-module-federation");
5
- Object.defineProperty(exports, "withModuleFederation", { enumerable: true, get: function () { return with_module_federation_1.withModuleFederation; } });
6
- const with_module_federation_ssr_1 = require("./src/module-federation/with-module-federation-ssr");
7
- Object.defineProperty(exports, "withModuleFederationForSSR", { enumerable: true, get: function () { return with_module_federation_ssr_1.withModuleFederationForSSR; } });
4
+ const webpack_1 = require("@nx/module-federation/webpack");
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; } });
8
8
  // Support for older generated code: `const withModuleFederation = require('@nx/react/module-federation')`
9
- module.exports = with_module_federation_1.withModuleFederation;
9
+ /**
10
+ * @deprecated Use `@nx/module-federation/webpack` instead. This will be removed in Nx v22.
11
+ */
12
+ module.exports = webpack_1.withModuleFederation;
10
13
  // Allow newer generated code to work: `const { withModuleFederation } = require(...)`;
11
- module.exports.withModuleFederation = with_module_federation_1.withModuleFederation;
12
- module.exports.withModuleFederationForSSR = with_module_federation_ssr_1.withModuleFederationForSSR;
14
+ /**
15
+ * @deprecated Use `@nx/module-federation/webpack` instead. This will be removed in Nx v22.
16
+ */
17
+ module.exports.withModuleFederation = webpack_1.withModuleFederation;
18
+ /**
19
+ * @deprecated Use `@nx/module-federation/webpack` instead. This will be removed in Nx v22.
20
+ */
21
+ module.exports.withModuleFederationForSSR = webpack_2.withModuleFederationForSSR;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react",
3
- "version": "0.0.0-pr-28808-a9a1b13",
3
+ "version": "0.0.0-pr-29047-57d3073",
4
4
  "private": false,
5
5
  "description": "The React plugin for Nx contains executors and generators for managing React applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Vitest, Playwright, Cypress, and Storybook.\n\n- Generators for applications, libraries, components, hooks, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
@@ -38,12 +38,11 @@
38
38
  "minimatch": "9.0.3",
39
39
  "picocolors": "^1.1.0",
40
40
  "tslib": "^2.3.0",
41
- "@module-federation/enhanced": "0.6.9",
42
- "@nx/devkit": "0.0.0-pr-28808-a9a1b13",
43
- "@nx/js": "0.0.0-pr-28808-a9a1b13",
44
- "@nx/eslint": "0.0.0-pr-28808-a9a1b13",
45
- "@nx/web": "0.0.0-pr-28808-a9a1b13",
46
- "@nx/module-federation": "0.0.0-pr-28808-a9a1b13",
41
+ "@nx/devkit": "0.0.0-pr-29047-57d3073",
42
+ "@nx/js": "0.0.0-pr-29047-57d3073",
43
+ "@nx/eslint": "0.0.0-pr-29047-57d3073",
44
+ "@nx/web": "0.0.0-pr-29047-57d3073",
45
+ "@nx/module-federation": "0.0.0-pr-29047-57d3073",
47
46
  "express": "^4.19.2",
48
47
  "http-proxy-middleware": "^3.0.3"
49
48
  },
@@ -15,7 +15,6 @@ const devkit_1 = require("@nx/devkit");
15
15
  const init_1 = require("../init/init");
16
16
  const eslint_1 = require("@nx/eslint");
17
17
  const versions_1 = require("../../utils/versions");
18
- const maybe_js_1 = require("../../utils/maybe-js");
19
18
  const install_common_dependencies_1 = require("./lib/install-common-dependencies");
20
19
  const create_ts_config_1 = require("../../utils/create-ts-config");
21
20
  const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
@@ -27,8 +26,8 @@ const js_1 = require("@nx/js");
27
26
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
28
27
  const setup_tailwind_1 = require("../setup-tailwind/setup-tailwind");
29
28
  const flat_config_1 = require("@nx/eslint/src/utils/flat-config");
30
- const add_project_root_to_rspack_plugin_excludes_1 = require("./lib/add-project-root-to-rspack-plugin-excludes");
31
29
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
30
+ const add_project_root_to_rspack_plugin_excludes_1 = require("./lib/add-project-root-to-rspack-plugin-excludes");
32
31
  async function addLinting(host, options) {
33
32
  const tasks = [];
34
33
  if (options.linter === eslint_1.Linter.EsLint) {
@@ -74,17 +73,16 @@ async function applicationGenerator(host, schema) {
74
73
  });
75
74
  }
76
75
  async function applicationGeneratorInternal(host, schema) {
76
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'application');
77
77
  const tasks = [];
78
+ const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
79
+ (0, show_possible_warnings_1.showPossibleWarnings)(host, options);
78
80
  const jsInitTask = await (0, js_1.initGenerator)(host, {
79
81
  ...schema,
80
82
  tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
81
83
  skipFormat: true,
82
- addTsPlugin: schema.useTsSolution,
83
- formatter: schema.formatter,
84
84
  });
85
85
  tasks.push(jsInitTask);
86
- const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
87
- (0, show_possible_warnings_1.showPossibleWarnings)(host, options);
88
86
  const initTask = await (0, init_1.default)(host, {
89
87
  ...options,
90
88
  skipFormat: true,
@@ -117,6 +115,15 @@ async function applicationGeneratorInternal(host, schema) {
117
115
  tasks.push(ensureDependencies(host, { uiFramework: 'react' }));
118
116
  }
119
117
  }
118
+ else if (options.bundler === 'rspack') {
119
+ const { rspackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxRspackVersion);
120
+ const rspackInitTask = await rspackInitGenerator(host, {
121
+ ...options,
122
+ addPlugin: false,
123
+ skipFormat: true,
124
+ });
125
+ tasks.push(rspackInitTask);
126
+ }
120
127
  if (!options.rootProject) {
121
128
  (0, create_ts_config_1.extractTsConfigBase)(host);
122
129
  }
@@ -144,7 +151,6 @@ async function applicationGeneratorInternal(host, schema) {
144
151
  compiler: options.compiler,
145
152
  skipFormat: true,
146
153
  addPlugin: options.addPlugin,
147
- projectType: 'application',
148
154
  });
149
155
  tasks.push(viteTask);
150
156
  createOrEditViteConfig(host, {
@@ -166,19 +172,6 @@ async function applicationGeneratorInternal(host, schema) {
166
172
  }, false);
167
173
  }
168
174
  else if (options.bundler === 'rspack') {
169
- const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxVersion);
170
- const rspackTask = await configurationGenerator(host, {
171
- project: options.projectName,
172
- main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)({
173
- js: options.js,
174
- useJsx: true,
175
- }, `src/main.tsx`)),
176
- tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
177
- target: 'web',
178
- newProject: true,
179
- framework: 'react',
180
- });
181
- tasks.push(rspackTask);
182
175
  (0, add_project_root_to_rspack_plugin_excludes_1.addProjectRootToRspackPluginExcludesIfExists)(host, options.appProjectRoot);
183
176
  }
184
177
  if (options.bundler !== 'vite' && options.unitTestRunner === 'vitest') {
@@ -253,11 +246,6 @@ async function applicationGeneratorInternal(host, schema) {
253
246
  });
254
247
  `);
255
248
  }
256
- (0, ts_solution_setup_1.updateTsconfigFiles)(host, options.appProjectRoot, 'tsconfig.app.json', {
257
- jsx: 'react-jsx',
258
- module: 'esnext',
259
- moduleResolution: 'bundler',
260
- });
261
249
  if (!options.skipFormat) {
262
250
  await (0, devkit_1.formatFiles)(host);
263
251
  }
@@ -0,0 +1,53 @@
1
+ <%_ if (rspackPluginOptions) { _%>
2
+ const { NxAppRspackPlugin } = require('@nx/rspack/app-plugin');
3
+ const { NxReactRspackPlugin } = require('@nx/rspack/react-plugin');
4
+ const { join } = require('path');
5
+
6
+ module.exports = {
7
+ output: {
8
+ path: join(__dirname, '<%= offsetFromRoot %><%= rspackPluginOptions.outputPath %>'),
9
+ },
10
+ devServer: {
11
+ port: 4200,
12
+ historyApiFallback: {
13
+ index: '/index.html',
14
+ disableDotRule: true,
15
+ htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'],
16
+ },
17
+ },
18
+ plugins: [
19
+ new NxAppRspackPlugin({
20
+ tsConfig: '<%= rspackPluginOptions.tsConfig %>',
21
+ main: '<%= rspackPluginOptions.main %>',
22
+ index: '<%= rspackPluginOptions.index %>',
23
+ baseHref: '<%= rspackPluginOptions.baseHref %>',
24
+ assets: <%- JSON.stringify(rspackPluginOptions.assets) %>,
25
+ styles: <%- JSON.stringify(rspackPluginOptions.styles) %>,
26
+ outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none',
27
+ optimization: process.env['NODE_ENV'] === 'production',
28
+ }),
29
+ new NxReactRspackPlugin({
30
+ // Uncomment this line if you don't want to use SVGR
31
+ // See: https://react-svgr.com/
32
+ // svgr: false
33
+ }),
34
+ ],
35
+ };
36
+ <%_ } else { _%>
37
+ const { composePlugins, withNx, withReact } = require('@nx/rspack');
38
+
39
+ // Nx plugins for rspack.
40
+ module.exports = composePlugins(
41
+ withNx(),
42
+ withReact({
43
+ // Uncomment this line if you don't want to use SVGR
44
+ // See: https://react-svgr.com/
45
+ // svgr: false
46
+ }),
47
+ (config) => {
48
+ // Update the rspack config as needed here.
49
+ // e.g. `config.plugins.push(new MyPlugin())`
50
+ return config;
51
+ }
52
+ );
53
+ <%_ } _%>
@@ -1,31 +1,14 @@
1
- <%_ if (isUsingTsSolutionSetup) { _%>{
2
- "extends": "<%= offsetFromRoot%>tsconfig.base.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
6
- "jsx": "react-jsx",
7
- "lib": ["dom"],
8
- "types": [
9
- "node",
10
- <%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
11
- "@nx/react/typings/cssmodule.d.ts",
12
- "@nx/react/typings/image.d.ts"
13
- ]
14
- },
15
- "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
16
- "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
17
- }<% } else { %>{
1
+ {
18
2
  "extends": "./tsconfig.json",
19
3
  "compilerOptions": {
20
4
  "outDir": "<%= offsetFromRoot %>dist/out-tsc",
21
5
  "types": [
22
6
  "node",
23
- <%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
7
+ <%_ if (style === 'styled-jsx') { %>"@nx/react/typings/styled-jsx.d.ts",<% } _%>
24
8
  "@nx/react/typings/cssmodule.d.ts",
25
9
  "@nx/react/typings/image.d.ts"
26
- ]
10
+ ]
27
11
  },
28
- "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
12
+ "exclude": ["jest.config.ts","src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
29
13
  "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
30
14
  }
31
- <% } %>
@@ -1,20 +1,4 @@
1
- <%_ if (isUsingTsSolutionSetup) { _%>{
2
- "extends": "<%= offsetFromRoot%>tsconfig.base.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
6
- "jsx": "react-jsx",
7
- "lib": ["dom"],
8
- "types": [
9
- "node",
10
- <%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
11
- "@nx/react/typings/cssmodule.d.ts",
12
- "@nx/react/typings/image.d.ts"
13
- ]
14
- },
15
- "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
16
- "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
17
- }<% } else { %>{
1
+ {
18
2
  "extends": "./tsconfig.json",
19
3
  "compilerOptions": {
20
4
  "outDir": "<%= offsetFromRoot %>dist/out-tsc",
@@ -23,9 +7,8 @@
23
7
  <%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
24
8
  "@nx/react/typings/cssmodule.d.ts",
25
9
  "@nx/react/typings/image.d.ts"
26
- ]
10
+ ]
27
11
  },
28
12
  "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
29
13
  "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
30
14
  }
31
- <% } %>
@@ -1,20 +1,4 @@
1
- <%_ if (isUsingTsSolutionSetup) { _%>{
2
- "extends": "<%= offsetFromRoot%>tsconfig.base.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
6
- "jsx": "react-jsx",
7
- "lib": ["dom"],
8
- "types": [
9
- "node",
10
- <%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
11
- "@nx/react/typings/cssmodule.d.ts",
12
- "@nx/react/typings/image.d.ts"
13
- ]
14
- },
15
- "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
16
- "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
17
- }<% } else { %>{
1
+ {
18
2
  "extends": "./tsconfig.json",
19
3
  "compilerOptions": {
20
4
  "outDir": "<%= offsetFromRoot %>dist/out-tsc",
@@ -23,9 +7,8 @@
23
7
  <%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
24
8
  "@nx/react/typings/cssmodule.d.ts",
25
9
  "@nx/react/typings/image.d.ts"
26
- ]
10
+ ]
27
11
  },
28
- "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
12
+ "exclude": ["jest.config.ts","src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
29
13
  "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
30
14
  }
31
- <% } %>
@@ -1,8 +1,8 @@
1
1
  <% if (classComponent) { %>
2
2
  import { Component } from 'react';
3
3
  <%_ } _%>
4
- // Uncomment this line to use CSS modules
5
- // import styles from './<%= fileName %>.module.<%= style %>';
4
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
+ import styles from './<%= fileName %>.module.<%= style %>';
6
6
  <%_ if (!minimal) { _%>
7
7
  import NxWelcome from "./nx-welcome";
8
8
  <%_ } _%>
@@ -1,3 +1,3 @@
1
- import { GeneratorCallback, Tree } from '@nx/devkit';
1
+ import type { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import { NormalizedSchema } from '../schema';
3
3
  export declare function addE2e(tree: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
@@ -36,27 +36,14 @@ async function addE2e(tree, options) {
36
36
  switch (options.e2eTestRunner) {
37
37
  case 'cypress': {
38
38
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
39
- if (options.isUsingTsSolutionConfig) {
40
- (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
41
- name: options.e2eProjectName,
42
- version: '0.0.1',
43
- private: true,
44
- nx: {
45
- projectType: 'application',
46
- implicitDependencies: [options.projectName],
47
- },
48
- });
49
- }
50
- else {
51
- (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
52
- projectType: 'application',
53
- root: options.e2eProjectRoot,
54
- sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
55
- targets: {},
56
- implicitDependencies: [options.projectName],
57
- tags: [],
58
- });
59
- }
39
+ (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
40
+ projectType: 'application',
41
+ root: options.e2eProjectRoot,
42
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
43
+ targets: {},
44
+ implicitDependencies: [options.projectName],
45
+ tags: [],
46
+ });
60
47
  const e2eTask = await configurationGenerator(tree, {
61
48
  ...options,
62
49
  project: options.e2eProjectName,
@@ -101,26 +88,13 @@ async function addE2e(tree, options) {
101
88
  }
102
89
  case 'playwright': {
103
90
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
104
- if (options.isUsingTsSolutionConfig) {
105
- (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
106
- name: options.e2eProjectName,
107
- version: '0.0.1',
108
- private: true,
109
- nx: {
110
- name: options.e2eProjectName,
111
- implicitDependencies: [options.projectName],
112
- },
113
- });
114
- }
115
- else {
116
- (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
117
- projectType: 'application',
118
- root: options.e2eProjectRoot,
119
- sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
120
- targets: {},
121
- implicitDependencies: [options.projectName],
122
- });
123
- }
91
+ (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
92
+ projectType: 'application',
93
+ root: options.e2eProjectRoot,
94
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
95
+ targets: {},
96
+ implicitDependencies: [options.projectName],
97
+ });
124
98
  const e2eTask = await configurationGenerator(tree, {
125
99
  project: options.e2eProjectName,
126
100
  skipFormat: true,
@@ -16,6 +16,5 @@ async function addJest(host, options) {
16
16
  setupFile: 'none',
17
17
  compiler: options.compiler,
18
18
  skipFormat: true,
19
- runtimeTsconfigFileName: 'tsconfig.app.json',
20
19
  });
21
20
  }
@@ -4,7 +4,7 @@ exports.addProject = addProject;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
6
6
  const maybe_js_1 = require("../../../utils/maybe-js");
7
- const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
7
+ const has_rspack_plugin_1 = require("../../../utils/has-rspack-plugin");
8
8
  function addProject(host, options) {
9
9
  const project = {
10
10
  root: options.appProjectRoot,
@@ -21,21 +21,74 @@ function addProject(host, options) {
21
21
  };
22
22
  }
23
23
  }
24
- if (options.isUsingTsSolutionConfig) {
25
- (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
26
- name: (0, get_import_path_1.getImportPath)(host, options.name),
27
- version: '0.0.1',
28
- private: true,
29
- nx: {
30
- name: options.name,
31
- },
32
- });
33
- }
34
- if (!options.isUsingTsSolutionConfig || options.alwaysGenerateProjectJson) {
35
- (0, devkit_1.addProjectConfiguration)(host, options.projectName, {
36
- ...project,
37
- });
24
+ else if (options.bundler === 'rspack' &&
25
+ (!(0, has_rspack_plugin_1.hasRspackPlugin)(host) || !options.addPlugin)) {
26
+ project.targets = {
27
+ build: createRspackBuildTarget(options),
28
+ serve: createRspackServeTarget(options),
29
+ };
38
30
  }
31
+ (0, devkit_1.addProjectConfiguration)(host, options.projectName, {
32
+ ...project,
33
+ });
34
+ }
35
+ function createRspackBuildTarget(options) {
36
+ return {
37
+ executor: '@nx/rspack:rspack',
38
+ outputs: ['{options.outputPath}'],
39
+ defaultConfiguration: 'production',
40
+ options: {
41
+ outputPath: (0, devkit_1.joinPathFragments)('dist', options.appProjectRoot),
42
+ index: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/index.html'),
43
+ baseHref: '/',
44
+ main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, `src/main.tsx`)),
45
+ tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
46
+ assets: [
47
+ (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/favicon.ico'),
48
+ (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/assets'),
49
+ ],
50
+ rspackConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'rspack.config.js'),
51
+ styles: options.styledModule || !options.hasStyles
52
+ ? []
53
+ : [
54
+ (0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/styles.${options.style}`),
55
+ ],
56
+ scripts: [],
57
+ configurations: {
58
+ development: {
59
+ mode: 'development',
60
+ },
61
+ production: {
62
+ mode: 'production',
63
+ optimization: true,
64
+ sourceMap: false,
65
+ outputHashing: 'all',
66
+ namedChunks: false,
67
+ extractLicenses: true,
68
+ vendorChunk: false,
69
+ },
70
+ },
71
+ },
72
+ };
73
+ }
74
+ function createRspackServeTarget(options) {
75
+ return {
76
+ executor: '@nx/rspack:dev-server',
77
+ defaultConfiguration: 'development',
78
+ options: {
79
+ buildTarget: `${options.projectName}:build`,
80
+ hmr: true,
81
+ },
82
+ configurations: {
83
+ development: {
84
+ buildTarget: `${options.projectName}:build:development`,
85
+ },
86
+ production: {
87
+ buildTarget: `${options.projectName}:build:production`,
88
+ hmr: false,
89
+ },
90
+ },
91
+ };
39
92
  }
40
93
  function createBuildTarget(options) {
41
94
  return {
@@ -10,7 +10,7 @@ const maybe_js_1 = require("../../../utils/maybe-js");
10
10
  const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
11
11
  const get_app_tests_1 = require("./get-app-tests");
12
12
  const onboarding_1 = require("nx/src/nx-cloud/utilities/onboarding");
13
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
13
+ const has_rspack_plugin_1 = require("../../../utils/has-rspack-plugin");
14
14
  async function createApplicationFiles(host, options) {
15
15
  let styleSolutionSpecificAppFiles;
16
16
  if (options.styledModule && options.style !== 'styled-jsx') {
@@ -47,7 +47,6 @@ async function createApplicationFiles(host, options) {
47
47
  inSourceVitestTests: (0, get_in_source_vitest_tests_template_1.getInSourceVitestTestsTemplate)(appTests),
48
48
  style: options.style === 'tailwind' ? 'css' : options.style,
49
49
  hasStyleFile,
50
- isUsingTsSolutionSetup: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host),
51
50
  };
52
51
  if (options.bundler === 'vite') {
53
52
  (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/base-vite'), options.appProjectRoot, templateVariables);
@@ -116,7 +115,12 @@ async function createApplicationFiles(host, options) {
116
115
  }
117
116
  }
118
117
  else if (options.bundler === 'rspack') {
119
- (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/base-rspack'), options.appProjectRoot, templateVariables);
118
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/base-rspack'), options.appProjectRoot, {
119
+ ...templateVariables,
120
+ rspackPluginOptions: (0, has_rspack_plugin_1.hasRspackPlugin)(host)
121
+ ? createNxRspackPluginOptions(options)
122
+ : null,
123
+ });
120
124
  }
121
125
  if (options.unitTestRunner === 'none' ||
122
126
  (options.unitTestRunner === 'vitest' && options.inSourceTests == true)) {
@@ -158,3 +162,24 @@ function createNxWebpackPluginOptions(options) {
158
162
  ],
159
163
  };
160
164
  }
165
+ function createNxRspackPluginOptions(options) {
166
+ return {
167
+ target: 'web',
168
+ outputPath: (0, devkit_1.joinPathFragments)('dist', options.appProjectRoot != '.'
169
+ ? options.appProjectRoot
170
+ : options.projectName),
171
+ index: './src/index.html',
172
+ baseHref: '/',
173
+ main: (0, maybe_js_1.maybeJs)({
174
+ js: options.js,
175
+ useJsx: true,
176
+ }, `./src/main.tsx`),
177
+ tsConfig: './tsconfig.app.json',
178
+ assets: ['./src/favicon.ico', './src/assets'],
179
+ styles: options.styledModule || !options.hasStyles
180
+ ? []
181
+ : [
182
+ `./src/styles.${options.style !== 'tailwind' ? options.style : 'css'}`,
183
+ ],
184
+ };
185
+ }
@@ -7,7 +7,6 @@ const devkit_1 = require("@nx/devkit");
7
7
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
8
8
  const assertion_1 = require("../../../utils/assertion");
9
9
  const find_free_port_1 = require("./find-free-port");
10
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
11
10
  function normalizeDirectory(options) {
12
11
  options.directory = options.directory?.replace(/\\{1,2}/g, '/');
13
12
  const { projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.directory);
@@ -52,7 +51,6 @@ async function normalizeOptions(host, options) {
52
51
  fileName,
53
52
  styledModule,
54
53
  hasStyles: options.style !== 'none',
55
- isUsingTsSolutionConfig: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host),
56
54
  };
57
55
  normalized.routing = normalized.routing ?? false;
58
56
  normalized.strict = normalized.strict ?? true;
@@ -17,11 +17,6 @@ function updateSpecConfig(host, options) {
17
17
  types.push('@nx/react/typings/cssmodule.d.ts', '@nx/react/typings/image.d.ts');
18
18
  compilerOptions.types = types;
19
19
  json.compilerOptions = compilerOptions;
20
- if (options.isUsingTsSolutionConfig) {
21
- // add project reference to the runtime tsconfig.app.json file
22
- json.references ??= [];
23
- json.references.push({ path: './tsconfig.app.json' });
24
- }
25
20
  return json;
26
21
  });
27
22
  if (options.unitTestRunner !== 'jest') {