So I've added this library which internally uses yjs (https://github.com/yjs/yjs
) to my payload project - and it's throwing these lovely esmodule errors.
How could I fix those?
Not sure ifhttps://payloadcms.com/docs/admin/webpack#aliasing-server-only-modules
is the problem - the error messages are babbling something about esmodules. But I'm not sure what I'd even put as an alias there
Not sure if it'll work with payload being CJS and the lib being ESM but i'm not super familiar with those details. I think the webpack alias is only for code you only want ran on the server and not the client
that coould be the case too - maybe the library has some code which runs on the server. I've seen that error on 2 different libraries which import something related to yjs
no idea how the hell I'd alias that, though
Aliasing the top level library works for me, i had a similary issue with a JWT / Cookie library
The strange part was I had to import the server library into a file and export it from that file. Then my app code would import that file/ I aliased that file vs the library directly
This seeems to have been the fix for some reason. Wasnt related to server-only stuff at all apparently
Get help straight from the Payload team with an Enterprise License.