Skip to content

[Case Study] Vercel+nextjs PnP compatibility #2031

Open
@kachkaev

Description

@kachkaev

What package is covered by this investigations?

Describe the goal of the investigation

Help Vercel users deploy their Next.js apps via GitHub (the same way it works for Yarn v1)

Investigation report

At the moment, it seems to be impossible to deploy a Next.js app using Yarn v2 into Vercel. You can find an example project in kachkaev/njt#29. The problem is being discussed in vercel/vercel#4910. Official issue: vercel/vercel#5280.

Most likely the blocker is in these lines: https://github.com/vercel/vercel/blob/c7e2280d231443917ecab2fffefdf0aea2a5bb78/packages/now-next/src/index.ts#L144-L154.

This takes us to a pretty popular resolve-from package and this issue in particular: sindresorhus/resolve-from#16. Maaaaybe the source of incompatibility is somewhere around here: https://github.com/sindresorhus/resolve-from/blob/188ed7da119c788d98272852e8a71fd19195f6cf/index.js#L29-L33.

I guess the reason for using resolveFrom in @vercel/next is the desire to support monorepos. A Next.js app is usually installed in the root of the repo (like in the example project I shared earlier), but it can also reside in packages/my-app-1 and packages/my-app-2, for instance. In practice, such apps may refer to different versions of next in their package.json files.

Given the popularity of all the three parts of the broken equation, it’d be great to get some help from the Yarn 2 community. Perhaps, the fix is not that complicated for those who understand the workings of PnP? Happy to help with testing! 🙌

Metadata

Metadata

Assignees

Labels

case studyPackage compatibility report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions