Open joaoguidev opened 9 months ago
The error means the library is trying to use the browser version, probably because Cloudflare picks the browser one instead of the Node one, and since it's not Node this is correct.
If you check their browser build, they just require this other package https://www.npmjs.com/package/dompurify and try to find them from window
first. They could just stop trying to find it globally in window
and instead just use ESM, but if they don't want to fix this on their side you could skip them and import dompurify
yourself.
Reproduction
https://stackblitz.com/~/github.com/joaoguidev/RemixDompurify
System Info
Used Package Manager
npm
Expected Behavior
Not get the error below when using Isomorphic-dompurify :
service core:user:worker: Uncaught ReferenceError: window is not defined at c77tsl6ez28.js:29540:22 in node_modules/isomorphic-dompurify/browser.js at c77tsl6ez28.js:82:50 at c77tsl6ez28.js:30604:43
Actual Behavior
Isomorphic-dompurify does not work with Remix because it seems Remix is trying to use the browser entry point from package.json on server. This problem is listed as a known issue on the Isomorphic-dompurify repository and refer to the issue #214