You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
In my project, we trying to integrate next-payload. However we still make use of the traditional /pages folder and we won't be moving those components any time soon.
I have noticed that, differently from components in the /app folder, any component in the /pages folder will break if trying to import a node_module.
I have tried to debug it without success, my hunch is that the use of @swc/register inside the withPayload is complicating things, however I couldn't find a way to fix it yet. I'll keep trying.
The text was updated successfully, but these errors were encountered:
as per Discord convo, my nextjs app is a CJS and it was working correctly with ESM modules like @uidotdev/usehooks or superjson (used by tRPC), but it stopped working once I wrapped my next config object with withPayload.
Your problem here is the package you are attempting to use @uidotdev/usehooks is ESM-only and is not able to be used in CJS projects. @denolfe
To further investigate if the issue is a limitation of Payload being a CJS, I have added the @uidotdev/usehooks into a component that is imported using the /app folder. In that case it worked perfectly. You can see it here.
As I see it, this strengthen the thesis that it's withPayload that is messing something up with the transpiration of files in the /pages folder.
In my project, we trying to integrate next-payload. However we still make use of the traditional /pages folder and we won't be moving those components any time soon.
I have noticed that, differently from components in the /app folder, any component in the /pages folder will break if trying to import a node_module.
I have created a very simple repro here:
payloadcms/next-payload-demo@main...valerioleo:next-payload-demo-fork:main
yarn install
yarn dev
I have tried to debug it without success, my hunch is that the use of
@swc/register
inside thewithPayload
is complicating things, however I couldn't find a way to fix it yet. I'll keep trying.The text was updated successfully, but these errors were encountered: