Skip to content

Commit

Permalink
fix(react): remove outdated packages (#16786)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndcunningham authored May 5, 2023
1 parent 83cbba2 commit 4750a1d
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 4 deletions.
6 changes: 6 additions & 0 deletions packages/react/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@
"version": "16.0.0-beta.1",
"description": "Replace @nrwl/react with @nx/react",
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
},
"update-16-1-0-remove-package": {
"cli": "nx",
"version": "16.1.0-beta.0",
"description": "Remove react-test-renderer from package.json",
"implementation": "./src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package"
}
},
"packageJsonUpdates": {
Expand Down
2 changes: 0 additions & 2 deletions packages/react/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
babelPresetReactVersion,
nxVersion,
reactDomVersion,
reactTestRendererVersion,
reactVersion,
testingLibraryReactVersion,
tsLibVersion,
Expand Down Expand Up @@ -63,7 +62,6 @@ function updateDependencies(host: Tree, schema: InitSchema) {
'@types/react': typesReactVersion,
'@types/react-dom': typesReactDomVersion,
'@testing-library/react': testingLibraryReactVersion,
'react-test-renderer': reactTestRendererVersion,
});
}

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 './update-16-1-0-remove-package';

describe('update-16-1-0-remove-package', () => {
let tree: Tree;
beforeEach(() => {
tree = createTreeWithEmptyWorkspace();

updateJson(tree, 'package.json', (json) => {
json.devDependencies['react-test-renderer'] = '18.2.0';
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);
}
6 changes: 6 additions & 0 deletions packages/web/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@
"version": "16.0.0-beta.4",
"description": "Replace @nrwl/web executors with @nx/webpack and @nx/rollup",
"implementation": "./src/migrations/update-16-0-0-update-executors/update-16-0-0-update-executors"
},
"update-16-1-0-remove-packages": {
"cli": "nx",
"version": "16.1.0-beta.0",
"description": "Remove core-js and regenerator-runtime packages",
"implementation": "./src/migrations/update-16-1-0-remove-packages/update-16-1-0-remove-packages"
}
},
"packageJsonUpdates": {
Expand Down
2 changes: 0 additions & 2 deletions packages/web/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ function updateDependencies(tree: Tree, schema: Schema) {
return addDependenciesToPackageJson(
tree,
{
'core-js': '^3.6.5',
'regenerator-runtime': '0.13.7',
tslib: tsLibVersion,
},
devDependencies
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Tree, readJson, updateJson } from '@nx/devkit';
import { createTreeWithEmptyWorkspace } from 'nx/src/devkit-testing-exports';
import removePackages from './update-16-1-0-remove-packages';

describe('update-16-1-0-remove-packages', () => {
let tree: Tree;
beforeEach(() => {
tree = createTreeWithEmptyWorkspace();

updateJson(tree, 'package.json', (json) => {
json.dependencies['core-js'] = '3.6.5';
json.dependencies['regenerator-runtime'] = '0.13.7';
return json;
});
});

it('should remove core-js & regenerator-runtime packages', async () => {
await removePackages(tree);

expect(
readJson(tree, 'package.json').dependencies['core-js']
).not.toBeDefined();
expect(
readJson(tree, 'package.json').dependencies['regenerator-runtime']
).not.toBeDefined();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {
Tree,
formatFiles,
removeDependenciesFromPackageJson,
} from '@nx/devkit';

export default async function removePackages(tree: Tree): Promise<void> {
removeDependenciesFromPackageJson(
tree,
['core-js', 'regenerator-runtime'],
[]
);

await formatFiles(tree);
}

1 comment on commit 4750a1d

@vercel
Copy link

@vercel vercel bot commented on 4750a1d May 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx.dev
nx-dev-nrwl.vercel.app

Please sign in to comment.