Skip to content

Commit 545746e

Browse files
SukkaWijjk
authored andcommittedAug 26, 2024
fix: properly patch lockfile against swc bindings (#66515)
A proper fix to #66448. The root cause of the issue is that Next.js gets SWC bindings list from `package.json`'s `optionalDependencies` when patching the lockfile. Recently Next.js added `sharp` to the `optionalDependencies`, which causes `sharp` to be wrongly treated as Next.js SWC bindings when matching versions (hence the `undefined`). The PR adds a filter after reading `optionalDependencies`. cc @huozhi @eps1lon Co-authored-by: JJ Kasper <jj@jjsweb.site>

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed
 

‎packages/next/src/lib/patch-incorrect-lockfile.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ export async function patchIncorrectLockfile(dir: string) {
5656

5757
const lockfileParsed = JSON.parse(content)
5858
const lockfileVersion = parseInt(lockfileParsed?.lockfileVersion, 10)
59-
const expectedSwcPkgs = Object.keys(nextPkgJson['optionalDependencies'] || {})
59+
const expectedSwcPkgs = Object.keys(
60+
nextPkgJson['optionalDependencies'] || {}
61+
).filter((pkg) => pkg.startsWith('@next/swc-'))
6062

6163
const patchDependency = (
6264
pkg: string,

0 commit comments

Comments
 (0)
Please sign in to comment.