Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/next/src/lib/patch-incorrect-lockfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ async function fetchPkgInfo(pkg: string) {
const data = await res.json()
const versionData = data.versions[nextPkgJson.version]

if (!versionData) {
return null
}

return {
os: versionData.os,
cpu: versionData.cpu,
Expand Down Expand Up @@ -60,7 +64,7 @@ export async function patchIncorrectLockfile(dir: string) {

const patchDependency = (
pkg: string,
pkgData: UnwrapPromise<ReturnType<typeof fetchPkgInfo>>
pkgData: NonNullable<UnwrapPromise<ReturnType<typeof fetchPkgInfo>>>
) => {
lockfileParsed.dependencies[pkg] = {
version: nextPkgJson.version,
Expand All @@ -72,7 +76,7 @@ export async function patchIncorrectLockfile(dir: string) {

const patchPackage = (
pkg: string,
pkgData: UnwrapPromise<ReturnType<typeof fetchPkgInfo>>
pkgData: NonNullable<UnwrapPromise<ReturnType<typeof fetchPkgInfo>>>
) => {
lockfileParsed.packages[pkg] = {
version: nextPkgJson.version,
Expand Down Expand Up @@ -151,6 +155,11 @@ export async function patchIncorrectLockfile(dir: string) {
const pkg = missingSwcPkgs[i]
const pkgData = pkgsData[i]

if (!pkgData) {
Log.warn(`Failed to fetch registry info for ${pkg}`)
continue
}

if (shouldPatchDependencies) {
patchDependency(pkg, pkgData)
}
Expand Down