Commit 545746e0 authored by Sukka's avatar Sukka Committed by Zack Tanner

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: 's avatarJJ Kasper <jj@jjsweb.site>
parent 26c80eeb
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment