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

fix(react): remove outdated packages #16786

Merged
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
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,
ndcunningham marked this conversation as resolved.
Show resolved Hide resolved
});
}

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) => {
ndcunningham marked this conversation as resolved.
Show resolved Hide resolved
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);
}