payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
24.48k stars 1.55k forks source link

Payload breaks with custom Babel config #7257

Closed ckruppe closed 2 months ago

ckruppe commented 3 months ago

Link to reproduction

No response

Payload Version

3.0.0-beta.67

Node Version

20.11.1

Next.js Version

15.0.0-rc.0

Describe the Bug

Payload breaks with custom babel config. As of incompatibillities with next/font. Following error gets thrown after 50 seconds and up compiling:

⨯ ./node_modules/@payloadcms/next/dist/layouts/Root/index.js:5:1 Syntax error: "next/font" requires SWC although Babel is being used due to a custom babel config being present. Read more: https://nextjs.org/docs/messages/babel-font-loader-conflict ⨯ ./node_modules/@payloadcms/next/dist/layouts/Root/index.js:5:1 Syntax error: "next/font" requires SWC although Babel is being used due to a custom babel config being present. Read more: https://nextjs.org/docs/messages/babel-font-loader-conflict

It would be good to at least have some option to opt out of this. We use at work many custom babel plugins that are needed for our usecases and this would prevent us from adapting Payload in our workflow.

Reproduction Steps

Using an babel config in your project is all whats needed to produce this error.

Adapters and Plugins

No response

ckruppe commented 2 months ago

One fast and simple fix would be to provide an second Root component that does not leverage next/font in the payload/next package. As the page lives already in userland, one could decide which to import. Only disadvantage would be that people maybe don't expect the long compile times with Babel because of loadash as it seems. (But could be warned against in the documentation).

I think it would really be an blocker for many to integrate payload in existing workflows that use babel as not all workflows can be easily swapped to swc. (Especially if your team does not know rust to convert custom plugins or has so many it does not have the time for that.)

jmikrut commented 2 months ago

@tylandavis this is another mention of Google fonts getting in the way of things. I would love to get around it somehow..... are there ANY good Windows / Linux / Mac OS serif fonts which are globally available?

tylandavis commented 2 months ago

I think we should go with Georgia as a replacement. It's installed on MacOS and Windows by default, and also slightly common on Linux. Georgia is slighly less-wide than Merriweather, but it is web-optimized and would look much better than say Times New Roman.

Merriweather: Screenshot 2024-07-23 at 3 06 16 PM

Georgia Screenshot 2024-07-23 at 3 07 22 PM

To cover our bases for Linux, we could use this font stack of Georgia-like fonts. (looks like it would cover most users)

font-family: Georgia, "Bitstream Charter", "Charis SIL", Utopia, "URW Bookman L", serif;

tylandavis commented 2 months ago

@ckruppe next/font has been removed in the latest beta (v3.0.0-beta.74) and is now optional.

ckruppe commented 2 months ago

Thanks very much for the fast mitigation. We do really appreciate your efforts. :)

github-actions[bot] commented 1 month ago

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.