Using GoTrue library in Sveltekit gives this error at build time: GoTrue is not a constructor

I have a sveltekit project that is using GoTrue library for authentication. In development mode (npm run dev) everything works but when I build for production (npm run build) it gives this error:

GoTrue is not a constructor

TypeError: GoTrue is not a constructor

Reproduction
GitHub repo: GitHub - ClaudiaGiv/sveltekit-tailwindcss-board

I also tested if the problem is with vite by creating a svelte project with vite and adding the GoTrue library and it works also on development mode and also the build for production. So considering this, it seems that the problem is strictly with sveltekit, not with vite but I don’t understand exactly why or how to fix it.

GitHub repo: GitHub - ClaudiaGiv/vite-svelte-project

Does anyone know or have any idea what could be the problem and how can it be fixed?

Thank you!

1 Like

Corresponding tweet for this thread:

Share link for this tweet.

1 Like