Skip to content

Commit

Permalink
fix: properly patch lockfile against swc bindings (#66515)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
2 people authored and ztanner committed Aug 26, 2024
1 parent 26c80ee commit 545746e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/next/src/lib/patch-incorrect-lockfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ export async function patchIncorrectLockfile(dir: string) {

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

const patchDependency = (
pkg: string,
Expand Down

0 comments on commit 545746e

Please sign in to comment.