Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Case Study] Vercel+nextjs PnP compatibility #2031

Open
kachkaev opened this issue Oct 22, 2020 · 6 comments
Open

[Case Study] Vercel+nextjs PnP compatibility #2031

kachkaev opened this issue Oct 22, 2020 · 6 comments
Assignees
Labels
case study Package compatibility report

Comments

@kachkaev
Copy link

kachkaev commented Oct 22, 2020

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! 🙌

@kachkaev kachkaev added the case study Package compatibility report label Oct 22, 2020
@merceyz
Copy link
Member

merceyz commented Oct 22, 2020

Just to echo this here as well

sindresorhus/resolve-from#16 (comment)
This package already supports PnP, it's using Module._resolveFilename which supports PnP, so there are no changes required here.


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

Depends, how does it get here? Is it something they invoke on their servers or is it run by the user?

We have a Discord server if you want to discuss this there

@merceyz merceyz changed the title [Case Study] resolve-from compatibility with yarn 2 (next.js / vercel context) [Case Study] Vercel+nextjs PnP compatibility Oct 22, 2020
@kachkaev
Copy link
Author

Is it something they invoke on their servers or is it run by the user?

I believe that @vercel/next package is fetched and executed in vercel.com CI. It is kicked off by the GitHub integration with Vercel, which means that there could be some environment-specific quirks. Interestingly, Vercel’s knowledge base explicitly elaborates on the limited Yarn 2 support: https://vercel.com/knowledge/does-vercel-support-yarn-2

What I see on my end is these logs – that’s not very helpful for this investigation probably.

As a user of Next.js and Vercel, I don’t have more insight unfortunately. Perhaps, @timneutkens or @Timer could link you to the right people? (sorry for spam-tagging folks 🙏)

@arcanis
Copy link
Member

arcanis commented Oct 22, 2020

I wonder is what is resolve-from good for? It seems to be pretty much createRequire (with more risks of breaking).

@kachkaev
Copy link
Author

Closing this as there is a solution now (setting FORCE_BUILDER_TAG=canary in Vercel dashbaord) 🎉

@merceyz
Copy link
Member

merceyz commented Dec 20, 2020

I'd argue that their solution isn't adding PnP support, it's forcibly disabling it :(

@kachkaev
Copy link
Author

@merceyz oh I see: vercel/vercel#5552 😔 Reopening

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
case study Package compatibility report
Projects
None yet
Development

No branches or pull requests

3 participants