Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(react): upgrade react-router-dom to 6.11.2 #17078

Merged
merged 1 commit into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
19 changes: 17 additions & 2 deletions packages/react/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -44,7 +41,7 @@ export function addRouting(host: Tree, options: NormalizedSchema) {
return addDependenciesToPackageJson(
host,
{ 'react-router-dom': reactRouterDomVersion },
{ '@types/react-router-dom': typesReactRouterDomVersion }
{}
);
}

Expand Down
7 changes: 2 additions & 5 deletions packages/react/src/generators/component/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
}
Expand Down
11 changes: 5 additions & 6 deletions packages/react/src/generators/library/lib/update-app-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {
Tree,
formatFiles,
removeDependenciesFromPackageJson,
} from '@nx/devkit';

export default async function removePackage(tree: Tree): Promise<void> {
removeDependenciesFromPackageJson(tree, [], ['react-test-renderer']);
await formatFiles(tree);
}
3 changes: 1 addition & 2 deletions packages/react/src/utils/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
52 changes: 12 additions & 40 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.