Isomorphism breaks due to Websockets when using SSR · Issue #155 · supabase/supabase-js (original) (raw)
Bug report
Describe the bug
When importing createClient
into a SvelteKit project, the following error is raised:
5:49:56 PM [vite] Error when evaluating SSR module /node_modules/websocket/lib/browser.js?v=f34fcf64:
Error: Could not determine global this
at /node_modules/websocket/lib/browser.js?v=f34fcf64:7:28
at instantiateModule (/home/ixxie/repos/minex/node_modules/vite/dist/node/chunks/dep-66eb515d.js:69030:166)
It seems to come from this block of code in the Websockets package.
To Reproduce
npm init svelte@next
npm install
npm install --save-prod @supabase/supabase-js
sed -i "s/<script>/<script>\n\timport { createClient } from '@supabase\/supabase-js';/" ./src/routes/index.svelte
npm run dev
Expected behavior
Import should work without error
Screenshots
If applicable, add screenshots to help explain your problem.
System information
- Version of supabase-js: 1.11.2
- Version of Node.js: 14.15.4
Additional context
This was discovered after resolving #153, after which @kiwicopple recommended I create a new issue.