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
27.67k stars 1.72k forks source link

fix: `getPayload` generate import map only in Next.js, move `ws` dependency to `@payloadcms/next` #9371

Open r1tsuu opened 2 days ago

r1tsuu commented 2 days ago

After the change with removing getPayloadHMR, we do generate import map even outside of Next.js, which leads to errors when using in a project without it: image

Also, the ws dependency shouldn't be included to the payload package, instead we can move it @payloadcms/next and import dynamically and we shouldn't try to connect to the Next.js WebSocket server if we're not inside of Next.js. Now, to control this we use the PAYLOAD_NEXT_INTEGRATION = 'true' env variable which we add in withPayload.