supabase-js: supabase-js fails with @sveltejs/kit (warning, sveltejs/kit is experimental)
Bug report
adding
import { createClient } from '@supabase/supabase-js'
into any script tag in a svelte project will cause a 500.
Describe the bug
I believe this has to do with svelte kit renders being executed on both the server side and client side. It also appears to be related to the javascript parser they use (meriyah). Starting the project, and opening a page containing the supabase import results in the following error:
500
[778:36]: Unexpected token: 'get'
SyntaxError: [778:36]: Unexpected token: 'get'
at report (/home/andrew/Code/development/telebum3/web/node_modules/.pnpm/@sveltejs/kit@1.0.0-next.5/node_modules/node_modules/.pnpm/meriyah@3.0.3/node_modules/meriyah/dist/meriyah.esm.js:182:11)
at matchOrInsertSemicolon (/home/andrew/Code/development/telebum3/web/node_modules/.pnpm/@sveltejs/kit@1.0.0-next.5/node_modules/node_modules/.pnpm/meriyah@3.0.3/node_modules/meriyah/dist/meriyah.esm.js:2096:9)
at parseLetIdentOrVarDeclarationStatement (/home/andrew/Code/development/telebum3/web/node_modules/.pnpm/@sveltejs/kit@1.0.0-next.5/node_modules/node_modules/.pnpm/meriyah@3.0.3/node_modules/meriyah/dist/meriyah.esm.js:3024:9)
at parseStatementListItem (/home/andrew/Code/development/telebum3/web/node_modules/.pnpm/@sveltejs/kit@1.0.0-next.5/node_modules/node_modules/.pnpm/meriyah@3.0.3/node_modules/meriyah/dist/meriyah.esm.js:2595:20)
at parseBlock (/home/andrew/Code/development/telebum3/web/node_modules/.pnpm/@sveltejs/kit@1.0.0-next.5/node_modules/node_modules/.pnpm/meriyah@3.0.3/node_modules/meriyah/dist/meriyah.esm.js:2692:19)
at parseTryStatement (/home/andrew/Code/development/telebum3/web/node_modules/.pnpm/@sveltejs/kit@1.0.0-next.5/node_modules/node_modules/.pnpm/meriyah@3.0.3/node_modules/meriyah/dist/meriyah.esm.js:2958:19)
at parseStatement (/home/andrew/Code/development/telebum3/web/node_modules/.pnpm/@sveltejs/kit@1.0.0-next.5/node_modules/node_modules/.pnpm/meriyah@3.0.3/node_modules/meriyah/dist/meriyah.esm.js:2641:20)
at parseStatementListItem (/home/andrew/Code/development/telebum3/web/node_modules/.pnpm/@sveltejs/kit@1.0.0-next.5/node_modules/node_modules/.pnpm/meriyah@3.0.3/node_modules/meriyah/dist/meriyah.esm.js:2611:20)
at parseFunctionBody (/home/andrew/Code/development/telebum3/web/node_modules/.pnpm/@sveltejs/kit@1.0.0-next.5/node_modules/node_modules/.pnpm/meriyah@3.0.3/node_modules/meriyah/dist/meriyah.esm.js:3800:19)
at parseFunctionExpression (/home/andrew/Code/development/telebum3/web/node_modules/.pnpm/@sveltejs/kit@1.0.0-next.5/node_modules/node_modules/.pnpm/meriyah@3.0.3/node_modules/meriyah/dist/meriyah.esm.js:4389:18)
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository: repro repo: https://github.com/andykais/supabase-svelte-kit-bug-repro
npm install
npm run dev
- Go to
http://localhost:3000
- See error
Expected behavior
supabase should ideally work in both the client and server environments of svelte kit.
Screenshots
N/A
System information
- OS: Linux, macOS
- Browser: Firefox & Chrome
- Version of supabase-js: 1.0.7
- Version of Node.js: 14.15.1
Additional context
Note: this is an error that is present in an experimental web framework. It is therefore likely a result of this project not being fully featured. Still, this feels like it is worth tracking.
I attempted dropping the supabase-js built files into the meriyah online compiler to see if the errors were visible there. However it appeared to compile the js code without any issue. There may be specific knobs that svelte kit has tweaked which cause the Unexpected token
error, but I am unsure.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 17 (2 by maintainers)
FWIW - installing as a dev dependency seems to resolve the issue in my SvelteKit project:
npm install -D @supabase/supabase-js
.Now that the sourcemap issue has been fixed we can see the real underlying error which is https://github.com/supabase/supabase-js/issues/155. I think this issue could be closed in favor of that one