@nx/react 0.0.0-pr-30418-0e58904 → 0.0.0-pr-29993-91cbae3

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 (42) hide show
  1. package/package.json +6 -6
  2. package/src/generators/application/application.js +4 -42
  3. package/src/generators/application/lib/add-e2e.js +2 -4
  4. package/src/generators/application/lib/add-linting.d.ts +0 -1
  5. package/src/generators/application/lib/add-linting.js +0 -38
  6. package/src/generators/application/lib/add-project.js +1 -12
  7. package/src/generators/application/lib/add-routing.js +1 -1
  8. package/src/generators/application/lib/bundlers/add-vite.js +6 -15
  9. package/src/generators/application/lib/create-application-files.js +3 -40
  10. package/src/generators/application/lib/install-common-dependencies.js +2 -13
  11. package/src/generators/application/lib/normalize-options.js +0 -3
  12. package/src/generators/application/schema.d.ts +0 -1
  13. package/src/generators/application/schema.json +1 -6
  14. package/src/generators/init/init.js +0 -23
  15. package/src/generators/init/schema.d.ts +0 -2
  16. package/src/generators/library/library.js +3 -3
  17. package/src/utils/ast-utils.d.ts +1 -1
  18. package/src/utils/ast-utils.js +2 -2
  19. package/src/utils/versions.d.ts +1 -3
  20. package/src/utils/versions.js +3 -6
  21. package/router-plugin.d.ts +0 -1
  22. package/router-plugin.js +0 -5
  23. package/src/generators/application/files/react-router-ssr/common/app/app-nav.tsx__tmpl__ +0 -15
  24. package/src/generators/application/files/react-router-ssr/common/app/entry.client.tsx__tmpl__ +0 -18
  25. package/src/generators/application/files/react-router-ssr/common/app/entry.server.tsx__tmpl__ +0 -74
  26. package/src/generators/application/files/react-router-ssr/common/app/root.tsx__tmpl__ +0 -51
  27. package/src/generators/application/files/react-router-ssr/common/app/routes/about.tsx__tmpl__ +0 -7
  28. package/src/generators/application/files/react-router-ssr/common/app/routes.tsx__tmpl__ +0 -6
  29. package/src/generators/application/files/react-router-ssr/common/public/favicon.ico +0 -0
  30. package/src/generators/application/files/react-router-ssr/common/react-router.config.ts__tmpl__ +0 -5
  31. package/src/generators/application/files/react-router-ssr/common/tests/routes/_index.spec.tsx__tmpl__ +0 -16
  32. package/src/generators/application/files/react-router-ssr/common/tsconfig.app.json__tmpl__ +0 -23
  33. package/src/generators/application/files/react-router-ssr/common/tsconfig.json__tmpl__ +0 -27
  34. package/src/generators/application/files/react-router-ssr/non-root/.gitignore__tmpl__ +0 -5
  35. package/src/generators/application/files/react-router-ssr/non-root/package.json__tmpl__ +0 -24
  36. package/src/generators/application/files/react-router-ssr/nx-welcome/claimed/app/nx-welcome.tsx__tmpl__ +0 -866
  37. package/src/generators/application/files/react-router-ssr/nx-welcome/not-configured/app/nx-welcome.tsx__tmpl__ +0 -866
  38. package/src/generators/application/files/react-router-ssr/nx-welcome/unclaimed/app/nx-welcome.tsx__tmpl__ +0 -864
  39. package/src/generators/application/files/react-router-ssr/ts-solution/package.json__tmpl__ +0 -24
  40. package/src/generators/application/files/react-router-ssr/ts-solution/tsconfig.app.json__tmpl__ +0 -39
  41. package/src/plugins/router-plugin.d.ts +0 -10
  42. package/src/plugins/router-plugin.js +0 -219
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react",
3
- "version": "0.0.0-pr-30418-0e58904",
3
+ "version": "0.0.0-pr-29993-91cbae3",
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,11 +38,11 @@
38
38
  "minimatch": "9.0.3",
39
39
  "picocolors": "^1.1.0",
40
40
  "tslib": "^2.3.0",
41
- "@nx/devkit": "0.0.0-pr-30418-0e58904",
42
- "@nx/js": "0.0.0-pr-30418-0e58904",
43
- "@nx/eslint": "0.0.0-pr-30418-0e58904",
44
- "@nx/web": "0.0.0-pr-30418-0e58904",
45
- "@nx/module-federation": "0.0.0-pr-30418-0e58904",
41
+ "@nx/devkit": "0.0.0-pr-29993-91cbae3",
42
+ "@nx/js": "0.0.0-pr-29993-91cbae3",
43
+ "@nx/eslint": "0.0.0-pr-29993-91cbae3",
44
+ "@nx/web": "0.0.0-pr-29993-91cbae3",
45
+ "@nx/module-federation": "0.0.0-pr-29993-91cbae3",
46
46
  "express": "^4.21.2",
47
47
  "http-proxy-middleware": "^3.0.3",
48
48
  "semver": "^7.6.3"
@@ -26,7 +26,6 @@ const add_rspack_1 = require("./lib/bundlers/add-rspack");
26
26
  const add_rsbuild_1 = require("./lib/bundlers/add-rsbuild");
27
27
  const add_vite_1 = require("./lib/bundlers/add-vite");
28
28
  const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
29
- const prompt_1 = require("@nx/devkit/src/generators/prompt");
30
29
  async function applicationGenerator(tree, schema) {
31
30
  return await applicationGeneratorInternal(tree, {
32
31
  addPlugin: false,
@@ -46,25 +45,6 @@ async function applicationGeneratorInternal(tree, schema) {
46
45
  });
47
46
  tasks.push(jsInitTask);
48
47
  const options = await (0, normalize_options_1.normalizeOptions)(tree, schema);
49
- options.useReactRouter = options.routing
50
- ? options.useReactRouter ??
51
- (await (0, prompt_1.promptWhenInteractive)({
52
- name: 'response',
53
- message: 'Would you like to use react-router for server-side rendering?',
54
- type: 'autocomplete',
55
- choices: [
56
- {
57
- name: 'Yes',
58
- message: 'I want to use react-router [ https://reactrouter.com/start/framework/routing ]',
59
- },
60
- {
61
- name: 'No',
62
- message: 'I do not want to use react-router for server-side rendering',
63
- },
64
- ],
65
- initial: 0,
66
- }, { response: 'No' }).then((r) => r.response === 'Yes'))
67
- : false;
68
48
  (0, show_possible_warnings_1.showPossibleWarnings)(tree, options);
69
49
  const initTask = await (0, init_1.default)(tree, {
70
50
  ...options,
@@ -133,34 +113,16 @@ async function applicationGeneratorInternal(tree, schema) {
133
113
  }
134
114
  // Handle tsconfig.spec.json for jest or vitest
135
115
  (0, update_jest_config_1.updateSpecConfig)(tree, options);
136
- const commonDependencyTask = await (0, install_common_dependencies_1.installCommonDependencies)(tree, options);
137
- tasks.push(commonDependencyTask);
116
+ const stylePreprocessorTask = await (0, install_common_dependencies_1.installCommonDependencies)(tree, options);
117
+ tasks.push(stylePreprocessorTask);
138
118
  const styledTask = (0, add_styled_dependencies_1.addStyledModuleDependencies)(tree, options);
139
119
  tasks.push(styledTask);
140
- if (!options.useReactRouter) {
141
- const routingTask = (0, add_routing_1.addRouting)(tree, options);
142
- tasks.push(routingTask);
143
- }
120
+ const routingTask = (0, add_routing_1.addRouting)(tree, options);
121
+ tasks.push(routingTask);
144
122
  (0, set_defaults_1.setDefaults)(tree, options);
145
123
  if (options.bundler === 'rspack' && options.style === 'styled-jsx') {
146
124
  (0, add_rspack_1.handleStyledJsxForRspack)(tasks, tree, options);
147
125
  }
148
- if (options.useReactRouter) {
149
- (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.json'), (json) => {
150
- const types = new Set(json.compilerOptions?.types || []);
151
- types.add('@react-router/node');
152
- return {
153
- ...json,
154
- compilerOptions: {
155
- ...json.compilerOptions,
156
- jsx: 'react-jsx',
157
- moduleResolution: 'bundler',
158
- types: Array.from(types),
159
- },
160
- };
161
- });
162
- }
163
- // Only for the new TS solution
164
126
  (0, ts_solution_setup_1.updateTsconfigFiles)(tree, options.appProjectRoot, 'tsconfig.app.json', {
165
127
  jsx: 'react-jsx',
166
128
  module: 'esnext',
@@ -28,10 +28,8 @@ async function addE2e(tree, options) {
28
28
  e2eWebServerInfo = await getWebpackE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `webpack.config.${options.js ? 'js' : 'ts'}`), options.addPlugin, options.devServerPort ?? 4200);
29
29
  }
30
30
  else if (options.bundler === 'vite') {
31
- const { getViteE2EWebServerInfo, getReactRouterE2EWebServerInfo } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
32
- e2eWebServerInfo = options.useReactRouter
33
- ? await getReactRouterE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `vite.config.${options.js ? 'js' : 'ts'}`), options.addPlugin, options.devServerPort ?? 4200)
34
- : await getViteE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `vite.config.${options.js ? 'js' : 'ts'}`), options.addPlugin, options.devServerPort ?? 4200);
31
+ const { getViteE2EWebServerInfo } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
32
+ e2eWebServerInfo = await getViteE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `vite.config.${options.js ? 'js' : 'ts'}`), options.addPlugin, options.devServerPort ?? 4200);
35
33
  }
36
34
  else if (options.bundler === 'rsbuild') {
37
35
  (0, devkit_1.ensurePackage)('@nx/rsbuild', versions_1.nxVersion);
@@ -1,4 +1,3 @@
1
1
  import { type Tree, type GeneratorCallback } from '@nx/devkit';
2
2
  import { NormalizedSchema } from '../schema';
3
3
  export declare function addLinting(host: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
4
- export declare function isEslintInstalled(tree: Tree): boolean;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addLinting = addLinting;
4
- exports.isEslintInstalled = isEslintInstalled;
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const eslint_1 = require("@nx/eslint");
7
6
  const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
@@ -9,7 +8,6 @@ const flat_config_1 = require("@nx/eslint/src/utils/flat-config");
9
8
  const devkit_2 = require("@nx/devkit");
10
9
  const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
11
10
  const lint_1 = require("../../../utils/lint");
12
- const versions_1 = require("../../../utils/versions");
13
11
  async function addLinting(host, options) {
14
12
  const tasks = [];
15
13
  if (options.linter === eslint_1.Linter.EsLint) {
@@ -45,42 +43,6 @@ async function addLinting(host, options) {
45
43
  const addSwcTask = (0, add_swc_dependencies_1.addSwcDependencies)(host);
46
44
  tasks.push(installTask, addSwcTask);
47
45
  }
48
- if (options.useReactRouter) {
49
- await ignoreReactRouterFilesInEslintConfig(host, options.appProjectRoot);
50
- }
51
46
  }
52
47
  return (0, devkit_2.runTasksInSerial)(...tasks);
53
48
  }
54
- async function ignoreReactRouterFilesInEslintConfig(tree, projectRoot) {
55
- if (!isEslintInstalled(tree)) {
56
- return;
57
- }
58
- (0, devkit_1.ensurePackage)('@nx/eslint', versions_1.nxVersion);
59
- const { addIgnoresToLintConfig, isEslintConfigSupported } = await Promise.resolve().then(() => require('@nx/eslint/src/generators/utils/eslint-file'));
60
- if (!isEslintConfigSupported(tree)) {
61
- return;
62
- }
63
- const { useFlatConfig } = await Promise.resolve().then(() => require('@nx/eslint/src/utils/flat-config'));
64
- const isUsingFlatConfig = useFlatConfig(tree);
65
- if (!projectRoot && !isUsingFlatConfig) {
66
- // root eslintrc files ignore all files and the root eslintrc files add
67
- // back all the project files, so we only add the ignores to the project
68
- // eslintrc files
69
- return;
70
- }
71
- // for flat config, we update the root config file
72
- const directory = isUsingFlatConfig ? '' : projectRoot ?? '';
73
- addIgnoresToLintConfig(tree, directory, ['**/build', '**/.react-router']);
74
- }
75
- function isEslintInstalled(tree) {
76
- try {
77
- require('eslint');
78
- return true;
79
- }
80
- catch { }
81
- // it might not be installed yet, but it might be in the tree pending install
82
- const { devDependencies, dependencies } = tree.exists('package.json')
83
- ? (0, devkit_1.readJson)(tree, 'package.json')
84
- : {};
85
- return !!devDependencies?.['eslint'] || !!dependencies?.['eslint'];
86
- }
@@ -52,18 +52,7 @@ function addProject(host, options) {
52
52
  });
53
53
  }
54
54
  if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
55
- // React Router already adds a package.json to the project root
56
- if (options.useReactRouter) {
57
- (0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), (json) => {
58
- return {
59
- name: packageJson.name,
60
- ...json,
61
- };
62
- });
63
- }
64
- else {
65
- (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
66
- }
55
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
67
56
  }
68
57
  }
69
58
  function createRspackBuildTarget(options) {
@@ -20,7 +20,7 @@ function addRouting(host, options) {
20
20
  }, `src/app/${options.fileName}.tsx`));
21
21
  const appFileContent = host.read(appPath, 'utf-8');
22
22
  const appSource = tsModule.createSourceFile(appPath, appFileContent, tsModule.ScriptTarget.Latest, true);
23
- const changes = (0, devkit_1.applyChangesToString)(appFileContent, (0, ast_utils_1.addInitialRoutes)(appPath, appSource, options.inSourceTests));
23
+ const changes = (0, devkit_1.applyChangesToString)(appFileContent, (0, ast_utils_1.addInitialRoutes)(appPath, appSource));
24
24
  host.write(appPath, changes);
25
25
  if (!options.skipPackageJson) {
26
26
  return (0, devkit_1.addDependenciesToPackageJson)(host, { 'react-router-dom': versions_1.reactRouterDomVersion }, {});
@@ -11,18 +11,6 @@ async function setupViteConfiguration(tree, options, tasks) {
11
11
  if (tree.exists((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/environments'))) {
12
12
  tree.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/environments'));
13
13
  }
14
- const reactRouterFrameworkConfig = {
15
- imports: [`import { reactRouter } from '@react-router/dev/vite'`],
16
- plugins: ['!process.env.VITEST && reactRouter()'],
17
- };
18
- const baseReactConfig = {
19
- imports: [
20
- options.compiler === 'swc'
21
- ? `import react from '@vitejs/plugin-react-swc'`
22
- : `import react from '@vitejs/plugin-react'`,
23
- ],
24
- plugins: ['react()'],
25
- };
26
14
  const viteTask = await viteConfigurationGenerator(tree, {
27
15
  uiFramework: 'react',
28
16
  project: options.projectName,
@@ -41,9 +29,12 @@ async function setupViteConfiguration(tree, options, tasks) {
41
29
  includeVitest: options.unitTestRunner === 'vitest',
42
30
  inSourceTests: options.inSourceTests,
43
31
  rollupOptionsExternal: ["'react'", "'react-dom'", "'react/jsx-runtime'"],
44
- ...(options.useReactRouter
45
- ? reactRouterFrameworkConfig
46
- : baseReactConfig),
32
+ imports: [
33
+ options.compiler === 'swc'
34
+ ? `import react from '@vitejs/plugin-react-swc'`
35
+ : `import react from '@vitejs/plugin-react'`,
36
+ ],
37
+ plugins: ['react()'],
47
38
  }, false);
48
39
  }
49
40
  async function setupVitestConfiguration(tree, options, tasks) {
@@ -12,7 +12,6 @@ const get_app_tests_1 = require("./get-app-tests");
12
12
  const onboarding_1 = require("nx/src/nx-cloud/utilities/onboarding");
13
13
  const has_rspack_plugin_1 = require("../../../utils/has-rspack-plugin");
14
14
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
15
- const versions_1 = require("../../../utils/versions");
16
15
  async function createApplicationFiles(host, options) {
17
16
  let styleSolutionSpecificAppFiles;
18
17
  if (options.styledModule && options.style !== 'styled-jsx') {
@@ -42,13 +41,6 @@ async function createApplicationFiles(host, options) {
42
41
  const templateVariables = {
43
42
  ...options.names,
44
43
  ...options,
45
- typesNodeVersion: versions_1.typesNodeVersion,
46
- typesReactDomVersion: versions_1.typesReactDomVersion,
47
- reactRouterVersion: versions_1.reactRouterVersion,
48
- typesReactVersion: versions_1.typesReactVersion,
49
- reactDomVersion: versions_1.reactDomVersion,
50
- reactVersion: versions_1.reactVersion,
51
- reactRouterIsBotVersion: versions_1.reactRouterIsBotVersion,
52
44
  js: !!options.js, // Ensure this is defined in template
53
45
  tmpl: '',
54
46
  offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
@@ -58,12 +50,9 @@ async function createApplicationFiles(host, options) {
58
50
  hasStyleFile,
59
51
  isUsingTsSolutionSetup: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host),
60
52
  };
61
- if (options.bundler === 'vite' && !options.useReactRouter) {
53
+ if (options.bundler === 'vite') {
62
54
  (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/base-vite'), options.appProjectRoot, templateVariables);
63
55
  }
64
- else if (options.bundler === 'vite' && options.useReactRouter) {
65
- generateReactRouterFiles(host, options, templateVariables);
66
- }
67
56
  else if (options.bundler === 'webpack') {
68
57
  (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/base-webpack'), options.appProjectRoot, {
69
58
  ...templateVariables,
@@ -148,12 +137,9 @@ async function createApplicationFiles(host, options) {
148
137
  const tutorialUrl = options.rootProject
149
138
  ? 'https://nx.dev/getting-started/tutorials/react-standalone-tutorial'
150
139
  : 'https://nx.dev/react-tutorial/1-code-generation?utm_source=nx-project';
151
- const path = options.useReactRouter
152
- ? '../files/react-router-ssr/nx-welcome'
153
- : '../files/nx-welcome';
154
- (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, path, onBoardingStatus), options.appProjectRoot, { ...templateVariables, connectCloudUrl, tutorialUrl });
140
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/nx-welcome', onBoardingStatus), options.appProjectRoot, { ...templateVariables, connectCloudUrl, tutorialUrl });
155
141
  }
156
- (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, styleSolutionSpecificAppFiles, options.useReactRouter ? 'src' : ''), options.appProjectRoot, templateVariables);
142
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, styleSolutionSpecificAppFiles), options.appProjectRoot, templateVariables);
157
143
  if (options.js) {
158
144
  (0, devkit_1.toJS)(host, {
159
145
  useJsx: options.bundler === 'vite' || options.bundler === 'rspack',
@@ -208,26 +194,3 @@ function createNxRspackPluginOptions(options, rootOffset) {
208
194
  ],
209
195
  };
210
196
  }
211
- function generateReactRouterFiles(tree, options, templateVariables) {
212
- (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, '../files/react-router-ssr/common'), options.appProjectRoot, templateVariables);
213
- if (options.rootProject) {
214
- const gitignore = tree.read('.gitignore', 'utf-8');
215
- tree.write('.gitignore', `${gitignore}\n.cache\nbuild\npublic/build\n.env\n\.react-router\n`);
216
- }
217
- else {
218
- (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../files/react-router-ssr/non-root'), options.appProjectRoot, templateVariables);
219
- }
220
- if (options.isUsingTsSolutionConfig) {
221
- (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../files/react-router-ssr/ts-solution'), options.appProjectRoot, templateVariables);
222
- (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), (json) => {
223
- if (options.projectName !== options.importPath) {
224
- json.nx = { name: options.projectName };
225
- }
226
- if (options.parsedTags?.length) {
227
- json.nx ??= {};
228
- json.nx.tags = options.parsedTags;
229
- }
230
- return json;
231
- });
232
- }
233
- }
@@ -11,24 +11,13 @@ async function installCommonDependencies(host, options) {
11
11
  const reactDeps = await (0, version_utils_1.getReactDependenciesVersionsToInstall)(host);
12
12
  const dependencies = {};
13
13
  const devDependencies = {
14
+ '@types/node': versions_1.typesNodeVersion,
14
15
  '@types/react': reactDeps['@types/react'],
15
16
  '@types/react-dom': reactDeps['@types/react-dom'],
16
- '@types/node': versions_1.typesNodeVersion,
17
- ...(options.useReactRouter
18
- ? {
19
- '@react-router/dev': versions_1.reactRouterVersion,
20
- }
21
- : {}),
22
17
  };
23
18
  if (options.bundler !== 'vite') {
24
19
  dependencies['tslib'] = versions_1.tsLibVersion;
25
20
  }
26
- if (options.useReactRouter) {
27
- dependencies['react-router'] = versions_1.reactRouterVersion;
28
- dependencies['@react-router/node'] = versions_1.reactRouterVersion;
29
- dependencies['@react-router/serve'] = versions_1.reactRouterVersion;
30
- dependencies['isbot'] = versions_1.reactRouterIsBotVersion;
31
- }
32
21
  // Vite requires style preprocessors to be installed manually.
33
22
  // `@nx/webpack` installs them automatically for now.
34
23
  if (options.bundler === 'vite' || options.unitTestRunner === 'vitest') {
@@ -56,5 +45,5 @@ async function installCommonDependencies(host, options) {
56
45
  devDependencies['@testing-library/react'] = versions_1.testingLibraryReactVersion;
57
46
  devDependencies['@testing-library/dom'] = versions_1.testingLibraryDomVersion;
58
47
  }
59
- return (0, devkit_1.addDependenciesToPackageJson)(host, dependencies, devDependencies);
48
+ return (0, devkit_1.addDependenciesToPackageJson)(host, {}, devDependencies);
60
49
  }
@@ -31,8 +31,6 @@ async function normalizeOptions(host, options) {
31
31
  ? null
32
32
  : options.style;
33
33
  (0, assertion_1.assertValidStyle)(options.style);
34
- options.bundler = options.useReactRouter ? 'vite' : options.bundler;
35
- options.useReactRouter = options.routing ? options.useReactRouter : false;
36
34
  const normalized = {
37
35
  ...options,
38
36
  projectName: appProjectName,
@@ -49,7 +47,6 @@ async function normalizeOptions(host, options) {
49
47
  useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
50
48
  };
51
49
  normalized.routing = normalized.routing ?? false;
52
- normalized.useReactRouter = normalized.useReactRouter ?? false;
53
50
  normalized.strict = normalized.strict ?? true;
54
51
  normalized.classComponent = normalized.classComponent ?? false;
55
52
  normalized.compiler = normalized.compiler ?? 'babel';
@@ -14,7 +14,6 @@ export interface Schema {
14
14
  linter: Linter | LinterType;
15
15
  classComponent?: boolean;
16
16
  routing?: boolean;
17
- useReactRouter?: boolean;
18
17
  skipNxJson?: boolean;
19
18
  js?: boolean;
20
19
  globalCss?: boolean;
@@ -83,12 +83,7 @@
83
83
  "routing": {
84
84
  "type": "boolean",
85
85
  "description": "Generate application with routes.",
86
- "x-prompt": "Would you like to add routing to this application?",
87
- "default": false
88
- },
89
- "useReactRouter": {
90
- "description": "Use React Router for routing.",
91
- "type": "boolean",
86
+ "x-prompt": "Would you like to add React Router to this application?",
92
87
  "default": false
93
88
  },
94
89
  "skipFormat": {
@@ -4,8 +4,6 @@ exports.reactInitGenerator = reactInitGenerator;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const versions_1 = require("../../utils/versions");
6
6
  const version_utils_1 = require("../../utils/version-utils");
7
- const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
8
- const router_plugin_1 = require("../../plugins/router-plugin");
9
7
  async function reactInitGenerator(tree, schema) {
10
8
  const tasks = [];
11
9
  if (!schema.skipPackageJson) {
@@ -18,27 +16,6 @@ async function reactInitGenerator(tree, schema) {
18
16
  '@nx/react': versions_1.nxVersion,
19
17
  }, undefined, schema.keepExistingVersions));
20
18
  }
21
- const nxJson = (0, devkit_1.readNxJson)(tree);
22
- schema.addPlugin ??=
23
- process.env.NX_ADD_PLUGINS !== 'false' &&
24
- nxJson.useInferencePlugins !== false;
25
- if (schema.addPlugin) {
26
- await (0, add_plugin_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/react/router-plugin', router_plugin_1.createNodesV2, {
27
- buildTargetName: ['build', 'react-router:build', 'react-router-build'],
28
- devTargetName: ['dev', 'react-router:dev', 'react-router-dev'],
29
- startTargetName: ['start', 'react-router-serve', 'react-router-start'],
30
- watchDepsTargetName: [
31
- 'watch-deps',
32
- 'react-router:watch-deps',
33
- 'react-router-watch-deps',
34
- ],
35
- buildDepsTargetName: [
36
- 'build-deps',
37
- 'react-router:build-deps',
38
- 'react-router-build-deps',
39
- ],
40
- }, schema.updatePackageScripts);
41
- }
42
19
  if (!schema.skipFormat) {
43
20
  await (0, devkit_1.formatFiles)(tree);
44
21
  }
@@ -2,6 +2,4 @@ export interface InitSchema {
2
2
  skipFormat?: boolean;
3
3
  skipPackageJson?: boolean;
4
4
  keepExistingVersions?: boolean;
5
- updatePackageScripts?: boolean;
6
- addPlugin?: boolean;
7
5
  }
@@ -39,6 +39,9 @@ async function libraryGeneratorInternal(host, schema) {
39
39
  });
40
40
  tasks.push(jsInitTask);
41
41
  const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
42
+ if (options.isUsingTsSolutionConfig) {
43
+ await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
44
+ }
42
45
  if (options.publishable === true && !schema.importPath) {
43
46
  throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
44
47
  }
@@ -78,9 +81,6 @@ async function libraryGeneratorInternal(host, schema) {
78
81
  (0, devkit_1.writeJson)(host, `${options.projectRoot}/package.json`, packageJson);
79
82
  }
80
83
  (0, create_files_1.createFiles)(host, options);
81
- if (options.isUsingTsSolutionConfig) {
82
- await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
83
- }
84
84
  const lintTask = await (0, add_linting_1.addLinting)(host, options);
85
85
  tasks.push(lintTask);
86
86
  // Set up build target
@@ -11,7 +11,7 @@ export declare function findComponentImportPath(componentName: string, source: t
11
11
  export declare function findElements(source: ts.SourceFile, tagName: string): ts.Node[];
12
12
  export declare function findClosestOpening(tagName: string, node: ts.Node): ts.Node;
13
13
  export declare function isTag(tagName: string, node: ts.Node): boolean;
14
- export declare function addInitialRoutes(sourcePath: string, source: ts.SourceFile, addBrowserRouter?: boolean): StringChange[];
14
+ export declare function addInitialRoutes(sourcePath: string, source: ts.SourceFile): StringChange[];
15
15
  export declare function addRoute(sourcePath: string, source: ts.SourceFile, options: {
16
16
  routePath: string;
17
17
  componentName: string;
@@ -234,7 +234,7 @@ function isTag(tagName, node) {
234
234
  }
235
235
  return false;
236
236
  }
237
- function addInitialRoutes(sourcePath, source, addBrowserRouter) {
237
+ function addInitialRoutes(sourcePath, source) {
238
238
  if (!tsModule) {
239
239
  tsModule = (0, ensure_typescript_1.ensureTypescript)();
240
240
  }
@@ -281,7 +281,7 @@ function addInitialRoutes(sourcePath, source, addBrowserRouter) {
281
281
  `,
282
282
  };
283
283
  return [
284
- ...addImport(source, `import { Route, Routes, Link ${addBrowserRouter ? ', BrowserRouter ' : ''}} from 'react-router-dom';`),
284
+ ...addImport(source, `import { Route, Routes, Link } from 'react-router-dom';`),
285
285
  insertRoutes,
286
286
  ];
287
287
  }
@@ -14,7 +14,7 @@ export declare const typesReactDomVersion = "19.0.0";
14
14
  export declare const typesReactIsV18Version = "18.3.0";
15
15
  export declare const typesReactIsVersion = "19.0.0";
16
16
  export declare const reactViteVersion = "^4.2.0";
17
- export declare const typesNodeVersion = "^20.0.0";
17
+ export declare const typesNodeVersion = "18.16.9";
18
18
  export declare const babelPresetReactVersion = "^7.14.5";
19
19
  export declare const babelCoreVersion = "^7.14.5";
20
20
  export declare const styledComponentsVersion = "5.3.6";
@@ -24,8 +24,6 @@ export declare const emotionReactVersion = "11.11.1";
24
24
  export declare const emotionBabelPlugin = "11.11.0";
25
25
  export declare const styledJsxVersion = "5.1.2";
26
26
  export declare const reactRouterDomVersion = "6.29.0";
27
- export declare const reactRouterVersion = "^7.2.0";
28
- export declare const reactRouterIsBotVersion = "^4.4.0";
29
27
  export declare const testingLibraryReactVersion = "16.1.0";
30
28
  export declare const testingLibraryDomVersion = "10.4.0";
31
29
  export declare const reduxjsToolkitVersion = "1.9.3";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sassVersion = exports.lessVersion = exports.moduleFederationEnhancedVersion = exports.moduleFederationNodeVersion = exports.typesCorsVersion = exports.corsVersion = exports.isbotVersion = exports.typesExpressVersion = exports.expressVersion = exports.autoprefixerVersion = exports.tailwindcssVersion = exports.postcssVersion = exports.tsLibVersion = exports.babelPluginStyledComponentsVersion = exports.eslintPluginReactHooksVersion = exports.eslintPluginReactVersion = exports.eslintPluginJsxA11yVersion = exports.eslintPluginImportVersion = exports.reactReduxVersion = exports.reduxjsToolkitVersion = exports.testingLibraryDomVersion = exports.testingLibraryReactVersion = exports.reactRouterIsBotVersion = exports.reactRouterVersion = exports.reactRouterDomVersion = exports.styledJsxVersion = exports.emotionBabelPlugin = exports.emotionReactVersion = exports.emotionStyledVersion = exports.typesStyledComponentsVersion = exports.styledComponentsVersion = exports.babelCoreVersion = exports.babelPresetReactVersion = exports.typesNodeVersion = exports.reactViteVersion = exports.typesReactIsVersion = exports.typesReactIsV18Version = exports.typesReactDomVersion = exports.typesReactDomV18Version = exports.typesReactVersion = exports.typesReactV18Version = exports.babelLoaderVersion = exports.swcLoaderVersion = exports.reactIsV18Version = exports.reactIsVersion = exports.reactDomV18Version = exports.reactDomVersion = exports.reactV18Version = exports.reactVersion = exports.nxVersion = void 0;
4
- exports.swcPluginStyledComponentsVersion = exports.swcPluginEmotionVersion = exports.swcPluginStyledJsxVersion = exports.svgrRollupVersion = exports.rollupPluginUrlVersion = void 0;
3
+ exports.svgrRollupVersion = exports.rollupPluginUrlVersion = exports.sassVersion = exports.lessVersion = exports.moduleFederationEnhancedVersion = exports.moduleFederationNodeVersion = exports.typesCorsVersion = exports.corsVersion = exports.isbotVersion = exports.typesExpressVersion = exports.expressVersion = exports.autoprefixerVersion = exports.tailwindcssVersion = exports.postcssVersion = exports.tsLibVersion = exports.babelPluginStyledComponentsVersion = exports.eslintPluginReactHooksVersion = exports.eslintPluginReactVersion = exports.eslintPluginJsxA11yVersion = exports.eslintPluginImportVersion = exports.reactReduxVersion = exports.reduxjsToolkitVersion = exports.testingLibraryDomVersion = exports.testingLibraryReactVersion = exports.reactRouterDomVersion = exports.styledJsxVersion = exports.emotionBabelPlugin = exports.emotionReactVersion = exports.emotionStyledVersion = exports.typesStyledComponentsVersion = exports.styledComponentsVersion = exports.babelCoreVersion = exports.babelPresetReactVersion = exports.typesNodeVersion = exports.reactViteVersion = exports.typesReactIsVersion = exports.typesReactIsV18Version = exports.typesReactDomVersion = exports.typesReactDomV18Version = exports.typesReactVersion = exports.typesReactV18Version = exports.babelLoaderVersion = exports.swcLoaderVersion = exports.reactIsV18Version = exports.reactIsVersion = exports.reactDomV18Version = exports.reactDomVersion = exports.reactV18Version = exports.reactVersion = exports.nxVersion = void 0;
4
+ exports.swcPluginStyledComponentsVersion = exports.swcPluginEmotionVersion = exports.swcPluginStyledJsxVersion = void 0;
5
5
  exports.nxVersion = require('../../package.json').version;
6
6
  exports.reactVersion = '19.0.0';
7
7
  exports.reactV18Version = '18.3.1';
@@ -18,8 +18,7 @@ exports.typesReactDomVersion = '19.0.0';
18
18
  exports.typesReactIsV18Version = '18.3.0';
19
19
  exports.typesReactIsVersion = '19.0.0';
20
20
  exports.reactViteVersion = '^4.2.0';
21
- // Needed for React-Router
22
- exports.typesNodeVersion = '^20.0.0';
21
+ exports.typesNodeVersion = '18.16.9';
23
22
  exports.babelPresetReactVersion = '^7.14.5';
24
23
  exports.babelCoreVersion = '^7.14.5';
25
24
  exports.styledComponentsVersion = '5.3.6';
@@ -30,8 +29,6 @@ exports.emotionBabelPlugin = '11.11.0';
30
29
  // WARNING: This needs to be in sync with Next.js' dependency or else there might be issues.
31
30
  exports.styledJsxVersion = '5.1.2';
32
31
  exports.reactRouterDomVersion = '6.29.0';
33
- exports.reactRouterVersion = '^7.2.0';
34
- exports.reactRouterIsBotVersion = '^4.4.0';
35
32
  exports.testingLibraryReactVersion = '16.1.0';
36
33
  exports.testingLibraryDomVersion = '10.4.0';
37
34
  exports.reduxjsToolkitVersion = '1.9.3';
@@ -1 +0,0 @@
1
- export { createNodesV2, ReactRouterPluginOptions, } from './src/plugins/router-plugin';
package/router-plugin.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNodesV2 = void 0;
4
- var router_plugin_1 = require("./src/plugins/router-plugin");
5
- Object.defineProperty(exports, "createNodesV2", { enumerable: true, get: function () { return router_plugin_1.createNodesV2; } });
@@ -1,15 +0,0 @@
1
- import * as React from "react";
2
- import { NavLink } from "react-router";
3
-
4
- export function AppNav() {
5
- return (
6
- <nav>
7
- <NavLink to="/" end>
8
- Home
9
- </NavLink>
10
- <NavLink to="/about" end>
11
- About
12
- </NavLink>
13
- </nav>
14
- );
15
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * By default, React Router will handle hydrating your app on the client for you.
3
- * You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx react-router reveal` ✨
4
- * For more information, see https://reactrouter.com/explanation/special-files#entryclienttsx
5
- */
6
-
7
- import { HydratedRouter } from 'react-router/dom';
8
- import { startTransition, StrictMode } from "react";
9
- import { hydrateRoot } from "react-dom/client";
10
-
11
- startTransition(() => {
12
- hydrateRoot(
13
- document,
14
- <StrictMode>
15
- <HydratedRouter />
16
- </StrictMode>
17
- );
18
- });