Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
fe4e4d2c
Unverified
Commit
fe4e4d2c
authored
Oct 22, 2024
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Oct 22, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
react-sync: Automatically update peer dependencies in libraries (#71636)
parent
08cd0e6e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
21 deletions
+27
-21
sync-react.js
scripts/sync-react.js
+27
-21
No files found.
scripts/sync-react.js
View file @
fe4e4d2c
...
@@ -20,8 +20,11 @@ const filesReferencingReactPeerDependencyVersion = [
...
@@ -20,8 +20,11 @@ const filesReferencingReactPeerDependencyVersion = [
'packages/create-next-app/templates/index.ts'
,
'packages/create-next-app/templates/index.ts'
,
'test/lib/next-modes/base.ts'
,
'test/lib/next-modes/base.ts'
,
]
]
const
appManifestsInstallingNextjsPeerDependencies
=
[
const
libraryManifestsSupportingNextjsReact
=
[
'packages/third-parties/package.json'
,
'packages/third-parties/package.json'
,
'packages/next/package.json'
,
]
const
appManifestsInstallingNextjsPeerDependencies
=
[
'examples/reproduction-template/package.json'
,
'examples/reproduction-template/package.json'
,
'test/.stats-app/package.json'
,
'test/.stats-app/package.json'
,
// TODO: These should use the usual test helpers that automatically install the right React version
// TODO: These should use the usual test helpers that automatically install the right React version
...
@@ -322,25 +325,6 @@ Or, run this command with no arguments to use the most recently published versio
...
@@ -322,25 +325,6 @@ Or, run this command with no arguments to use the most recently published versio
}
}
}
}
const
nextjsPackageJsonPath
=
path
.
join
(
process
.
cwd
(),
'packages'
,
'next'
,
'package.json'
)
const
nextjsPackageJson
=
JSON
.
parse
(
await
fsp
.
readFile
(
nextjsPackageJsonPath
,
'utf-8'
)
)
nextjsPackageJson
.
peerDependencies
.
react
=
`^18.2.0 ||
${
newVersionStr
}
`
nextjsPackageJson
.
peerDependencies
[
'react-dom'
]
=
`^18.2.0 ||
${
newVersionStr
}
`
await
fsp
.
writeFile
(
nextjsPackageJsonPath
,
JSON
.
stringify
(
nextjsPackageJson
,
null
,
2
)
+
// Prettier would add a newline anyway so do it manually to skip the additional `pnpm prettier-write`
'
\
n'
)
for
(
const
fileName
of
appManifestsInstallingNextjsPeerDependencies
)
{
for
(
const
fileName
of
appManifestsInstallingNextjsPeerDependencies
)
{
const
packageJsonPath
=
path
.
join
(
cwd
,
fileName
)
const
packageJsonPath
=
path
.
join
(
cwd
,
fileName
)
const
packageJson
=
await
fsp
.
readFile
(
packageJsonPath
,
'utf-8'
)
const
packageJson
=
await
fsp
.
readFile
(
packageJsonPath
,
'utf-8'
)
...
@@ -360,7 +344,29 @@ Or, run this command with no arguments to use the most recently published versio
...
@@ -360,7 +344,29 @@ Or, run this command with no arguments to use the most recently published versio
}
}
if
(
commit
)
{
if
(
commit
)
{
await
commitEverything
(
'Updated peer dependency references'
)
await
commitEverything
(
'Updated peer dependency references in apps'
)
}
for
(
const
fileName
of
libraryManifestsSupportingNextjsReact
)
{
const
packageJsonPath
=
path
.
join
(
cwd
,
fileName
)
const
packageJson
=
await
fsp
.
readFile
(
packageJsonPath
,
'utf-8'
)
const
manifest
=
JSON
.
parse
(
packageJson
)
if
(
manifest
.
peerDependencies
[
'react'
])
{
manifest
.
peerDependencies
[
'react'
]
=
`^18.2.0 ||
${
newVersionStr
}
`
}
if
(
manifest
.
peerDependencies
[
'react-dom'
])
{
manifest
.
peerDependencies
[
'react-dom'
]
=
`^18.2.0 ||
${
newVersionStr
}
`
}
await
fsp
.
writeFile
(
packageJsonPath
,
JSON
.
stringify
(
manifest
,
null
,
2
)
+
// Prettier would add a newline anyway so do it manually to skip the additional `pnpm prettier-write`
'
\
n'
)
}
if
(
commit
)
{
await
commitEverything
(
'Updated peer dependency references in libraries'
)
}
}
// Install the updated dependencies and build the vendored React files.
// Install the updated dependencies and build the vendored React files.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment