diff --git a/package.json b/package.json index 37e8e0ba38801..45cffffa5ebfc 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,6 @@ "@types/prettier": "^2.6.2", "@types/react": "18.0.25", "@types/react-dom": "18.0.9", - "@types/react-router-dom": "5.1.7", "@types/semver": "^7.3.8", "@types/tar-stream": "^2.2.2", "@types/tmp": "^0.2.0", @@ -230,7 +229,7 @@ "raw-loader": "^4.0.2", "react-redux": "8.0.5", "react-refresh": "^0.10.0", - "react-router-dom": "6.4.3", + "react-router-dom": "^6.11.2", "regenerator-runtime": "0.13.7", "resolve.exports": "1.1.0", "rollup": "^2.56.2", diff --git a/packages/react/migrations.json b/packages/react/migrations.json index 9c1f67f7db7d7..7b4e28329ac6c 100644 --- a/packages/react/migrations.json +++ b/packages/react/migrations.json @@ -95,6 +95,12 @@ "version": "16.2.0-beta.0", "description": "Remove react-test-renderer from package.json", "implementation": "./src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package" + }, + "remove-types-react-router-dom": { + "cli": "nx", + "version": "16.3.0-beta.2", + "description": "Remove @types/react-router-dom from package.json", + "implementation": "./src/migrations/update-16-3-0/remove-types-react-router-dom-package" } }, "packageJsonUpdates": { @@ -799,8 +805,8 @@ } } }, - "5.8.0": { - "version": "5.8.0-beta.0", + "15.8.0": { + "version": "15.8.0-beta.0", "packages": { "@types/react": { "version": "18.0.28", @@ -871,6 +877,15 @@ "alwaysAddToPackageJson": false } } + }, + "16.3.0": { + "version": "16.3.0-beta.2", + "packages": { + "react-router-dom": { + "version": "6.11.2", + "alwaysAddToPackageJson": false + } + } } } } diff --git a/packages/react/src/generators/application/lib/add-routing.ts b/packages/react/src/generators/application/lib/add-routing.ts index 3ea30287cece7..bbb45ad8dc699 100644 --- a/packages/react/src/generators/application/lib/add-routing.ts +++ b/packages/react/src/generators/application/lib/add-routing.ts @@ -1,9 +1,6 @@ import { addInitialRoutes } from '../../../utils/ast-utils'; import { NormalizedSchema } from '../schema'; -import { - reactRouterDomVersion, - typesReactRouterDomVersion, -} from '../../../utils/versions'; +import { reactRouterDomVersion } from '../../../utils/versions'; import { joinPathFragments, Tree, @@ -44,7 +41,7 @@ export function addRouting(host: Tree, options: NormalizedSchema) { return addDependenciesToPackageJson( host, { 'react-router-dom': reactRouterDomVersion }, - { '@types/react-router-dom': typesReactRouterDomVersion } + {} ); } diff --git a/packages/react/src/generators/component/component.ts b/packages/react/src/generators/component/component.ts index f5ff7aff60cc8..a5911cee3d6e0 100644 --- a/packages/react/src/generators/component/component.ts +++ b/packages/react/src/generators/component/component.ts @@ -18,10 +18,7 @@ import { addStyledModuleDependencies } from '../../rules/add-styled-dependencies import { assertValidStyle } from '../../utils/assertion'; import { addImport } from '../../utils/ast-utils'; import { getInSourceVitestTestsTemplate } from '../../utils/get-in-source-vitest-tests-template'; -import { - reactRouterDomVersion, - typesReactRouterDomVersion, -} from '../../utils/versions'; +import { reactRouterDomVersion } from '../../utils/versions'; import { getComponentTests } from './get-component-tests'; import { NormalizedSchema } from './noramlized-schema'; import { Schema } from './schema'; @@ -42,7 +39,7 @@ export async function componentGenerator(host: Tree, schema: Schema) { const routingTask = addDependenciesToPackageJson( host, { 'react-router-dom': reactRouterDomVersion }, - { '@types/react-router-dom': typesReactRouterDomVersion } + {} ); tasks.push(routingTask); } diff --git a/packages/react/src/generators/library/lib/update-app-routes.ts b/packages/react/src/generators/library/lib/update-app-routes.ts index a8b43e0c19a41..95d2f3625f26b 100644 --- a/packages/react/src/generators/library/lib/update-app-routes.ts +++ b/packages/react/src/generators/library/lib/update-app-routes.ts @@ -15,10 +15,7 @@ import { } from '../../../utils/ast-utils'; import { addInitialRoutes } from '../../../utils/ast-utils'; import { maybeJs } from './maybe-js'; -import { - reactRouterDomVersion, - typesReactRouterDomVersion, -} from '../../../utils/versions'; +import { reactRouterDomVersion } from '../../../utils/versions'; import { ensureTypescript } from '@nx/js/src/utils/typescript/ensure-typescript'; import { getImportPath } from '@nx/js/src/utils/get-import-path'; @@ -46,8 +43,10 @@ export function updateAppRoutes(host: Tree, options: NormalizedSchema) { const routerTask = addDependenciesToPackageJson( host, - { 'react-router-dom': reactRouterDomVersion }, - { '@types/react-router-dom': typesReactRouterDomVersion } + { + 'react-router-dom': reactRouterDomVersion, + }, + {} ); // addBrowserRouterToMain diff --git a/packages/react/src/migrations/update-16-3-0/remove-types-react-router-dom-package.spec.ts b/packages/react/src/migrations/update-16-3-0/remove-types-react-router-dom-package.spec.ts new file mode 100644 index 0000000000000..f83bb5555288b --- /dev/null +++ b/packages/react/src/migrations/update-16-3-0/remove-types-react-router-dom-package.spec.ts @@ -0,0 +1,23 @@ +import { Tree, readJson, updateJson } from '@nx/devkit'; +import { createTreeWithEmptyWorkspace } from 'nx/src/devkit-testing-exports'; +import removePackage from './remove-types-react-router-dom-package'; + +describe('update-16-3-0-remove-types-react-router-dom-package', () => { + let tree: Tree; + beforeEach(() => { + tree = createTreeWithEmptyWorkspace(); + + updateJson(tree, 'package.json', (json) => { + json.devDependencies['@types/react-router-dom'] = '*'; + return json; + }); + }); + + it('should remove react-test-renderer from package.json', async () => { + await removePackage(tree); + + expect( + readJson(tree, 'package.json').devDependencies['react-test-renderer'] + ).not.toBeDefined(); + }); +}); diff --git a/packages/react/src/migrations/update-16-3-0/remove-types-react-router-dom-package.ts b/packages/react/src/migrations/update-16-3-0/remove-types-react-router-dom-package.ts new file mode 100644 index 0000000000000..00b761a185508 --- /dev/null +++ b/packages/react/src/migrations/update-16-3-0/remove-types-react-router-dom-package.ts @@ -0,0 +1,10 @@ +import { + Tree, + formatFiles, + removeDependenciesFromPackageJson, +} from '@nx/devkit'; + +export default async function removePackage(tree: Tree): Promise { + removeDependenciesFromPackageJson(tree, [], ['react-test-renderer']); + await formatFiles(tree); +} diff --git a/packages/react/src/utils/versions.ts b/packages/react/src/utils/versions.ts index c3d7cc00be128..5fe866e406407 100755 --- a/packages/react/src/utils/versions.ts +++ b/packages/react/src/utils/versions.ts @@ -26,8 +26,7 @@ export const emotionBabelPlugin = '11.10.6'; // WARNING: This needs to be in sync with Next.js' dependency or else there might be issues. export const styledJsxVersion = '5.1.2'; -export const reactRouterDomVersion = '6.8.1'; -export const typesReactRouterDomVersion = '5.3.3'; +export const reactRouterDomVersion = '6.11.2'; export const testingLibraryReactVersion = '14.0.0'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 724dc7e48df4a..770f1dfac77dd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -403,9 +403,6 @@ devDependencies: '@types/react-dom': specifier: 18.0.9 version: 18.0.9 - '@types/react-router-dom': - specifier: 5.1.7 - version: 5.1.7 '@types/semver': specifier: ^7.3.8 version: 7.3.13 @@ -740,8 +737,8 @@ devDependencies: specifier: ^0.10.0 version: 0.10.0 react-router-dom: - specifier: 6.4.3 - version: 6.4.3(react-dom@18.2.0)(react@18.2.0) + specifier: ^6.11.2 + version: 6.11.2(react-dom@18.2.0)(react@18.2.0) resolve.exports: specifier: 1.1.0 version: 1.1.0 @@ -6603,8 +6600,8 @@ packages: reselect: 4.1.7 dev: true - /@remix-run/router@1.0.3: - resolution: {integrity: sha512-ceuyTSs7PZ/tQqi19YZNBc5X7kj1f8p+4DIyrcIYFY9h+hd1OKm4RqtiWldR9eGEvIiJfsqwM4BsuCtRIuEw6Q==} + /@remix-run/router@1.6.2: + resolution: {integrity: sha512-LzqpSrMK/3JBAVBI9u3NWtOhWNw5AMQfrUFYB0+bDHTSw17z++WJLsPsxAuK+oSddsxk4d7F/JcdDPM1M5YAhA==} engines: {node: '>=14'} dev: true @@ -8545,17 +8542,6 @@ packages: '@types/unist': 2.0.6 dev: false - /@types/history@4.7.11: - resolution: {integrity: sha512-qjDJRrmvBMiTx+jyLxvLfJU7UznFuokDv4f3WRuriHKERccVpFU+8XMQUAbDzoiJCsmexxRExQeMwwCdamSKDA==} - dev: true - - /@types/history@5.0.0: - resolution: {integrity: sha512-hy8b7Y1J8OGe6LbAjj3xniQrj3v6lsivCcrmf4TzSgPzLkhIeKgc5IZnT7ReIqmEuodjfO8EYAuoFvIrHi/+jQ==} - deprecated: This is a stub types definition. history provides its own type definitions, so you do not need this installed. - dependencies: - history: 5.3.0 - dev: true - /@types/hoist-non-react-statics@3.3.1: resolution: {integrity: sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==} dependencies: @@ -8760,21 +8746,6 @@ packages: '@types/react': 18.0.25 dev: true - /@types/react-router-dom@5.1.7: - resolution: {integrity: sha512-D5mHD6TbdV/DNHYsnwBTv+y73ei+mMjrkGrla86HthE4/PVvL1J94Bu3qABU+COXzpL23T1EZapVVpwHuBXiUg==} - dependencies: - '@types/history': 5.0.0 - '@types/react': 18.0.25 - '@types/react-router': 5.1.19 - dev: true - - /@types/react-router@5.1.19: - resolution: {integrity: sha512-Fv/5kb2STAEMT3wHzdKQK2z8xKq38EDIGVrutYLmQVVLe+4orDFquU52hQrULnEHinMKv9FSA6lf9+uNT1ITtA==} - dependencies: - '@types/history': 4.7.11 - '@types/react': 18.0.25 - dev: true - /@types/react@18.0.25: resolution: {integrity: sha512-xD6c0KDT4m7n9uD4ZHi02lzskaiqcBxf4zi+tXZY98a04wvc0hi/TcCPC2FOESZi51Nd7tlUeOJY8RofL799/g==} dependencies: @@ -15112,6 +15083,7 @@ packages: resolution: {integrity: sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==} dependencies: '@babel/runtime': 7.21.0 + dev: false /hoist-non-react-statics@3.3.2: resolution: {integrity: sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==} @@ -21188,26 +21160,26 @@ packages: engines: {node: '>=0.10.0'} dev: true - /react-router-dom@6.4.3(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-MiaYQU8CwVCaOfJdYvt84KQNjT78VF0TJrA17SIQgNHRvLnXDJO6qsFqq8F/zzB1BWZjCFIrQpu4QxcshitziQ==} + /react-router-dom@6.11.2(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-JNbKtAeh1VSJQnH6RvBDNhxNwemRj7KxCzc5jb7zvDSKRnPWIFj9pO+eXqjM69gQJ0r46hSz1x4l9y0651DKWw==} engines: {node: '>=14'} peerDependencies: react: '>=16.8' react-dom: '>=16.8' dependencies: - '@remix-run/router': 1.0.3 + '@remix-run/router': 1.6.2 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) - react-router: 6.4.3(react@18.2.0) + react-router: 6.11.2(react@18.2.0) dev: true - /react-router@6.4.3(react@18.2.0): - resolution: {integrity: sha512-BT6DoGn6aV1FVP5yfODMOiieakp3z46P1Fk0RNzJMACzE7C339sFuHebfvWtnB4pzBvXXkHP2vscJzWRuUjTtA==} + /react-router@6.11.2(react@18.2.0): + resolution: {integrity: sha512-74z9xUSaSX07t3LM+pS6Un0T55ibUE/79CzfZpy5wsPDZaea1F8QkrsiyRnA2YQ7LwE/umaydzXZV80iDCPkMg==} engines: {node: '>=14'} peerDependencies: react: '>=16.8' dependencies: - '@remix-run/router': 1.0.3 + '@remix-run/router': 1.6.2 react: 18.2.0 dev: true