Don't override use-sync-external-store peerDeps (#22882)

Usually the build script updates transitive React dependencies so that
they refer to the corresponding release version.

For use-sync-external-store, though, we also want to support older
versions of React, too. So the normal behavior of the build script
isn't sufficient.

For now, to unblock, I hardcoded a special case, but we should consider
a better way to handle this in the future.
This commit is contained in:
Andrew Clark 2021-12-08 02:26:12 -05:00 committed by GitHub
parent 06f403481f
commit ec78b135fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -20,6 +20,6 @@
],
"license": "MIT",
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0"
"react": "^16.8.0 || ^17.0.0 || ^18.0.0-rc"
}
}

View File

@ -45,6 +45,7 @@ module.exports = () => {
case 'experimental':
case 'alpha':
case 'beta':
case 'rc':
case 'untagged':
break;
default:

View File

@ -243,6 +243,13 @@ function updatePackageVersions(
}
}
if (packageInfo.peerDependencies) {
if (!pinToExactVersion && moduleName === 'use-sync-external-store') {
// use-sync-external-store supports older versions of React, too, so
// we don't override to the latest version. We should figure out some
// better way to handle this.
// TODO: Remove this special case.
continue;
}
for (const dep of Object.keys(packageInfo.peerDependencies)) {
const depVersion = versionsMap.get(dep);
if (depVersion !== undefined) {