supabase / auth-helpers

A collection of framework specific Auth utilities for working with Supabase.
https://supabase.github.io/auth-helpers/
MIT License
893 stars 240 forks source link

supabase/ssr export error in browser #725

Closed Aietes closed 5 months ago

Aietes commented 5 months ago

Bug report

Describe the bug

When using supabase/ssr in Nuxt, provided via a Nuxt module, I get the following error in the browser:

Uncaught SyntaxError: The requested module '/_nuxt/node_modules/.pnpm/cookie@0.5.0/node_modules/cookie/index.js?v=d88ad7de' does not provide an export named 'parse'

It comes from packages/ssr/src/utils/helpers.ts, where cookie helper functions are imported:

export { parse, serialize } from 'cookie';

Is there anything I can do about it? The issue seems to be that I'm using ssr in a ESM module, and the helper functions are CommonJS. There seem to be a pull request in the cookie library, but it's not merged yet, and ssr would still need to update the dependency.

Expected behavior

No module export error in the browser.

System information

Additional context

Add any other context about the problem here.

Aietes commented 5 months ago

I worked around the issue by pre-bundling the package using optimizeDeps in Vite. This fixes the error, I believe Vite fixes the imports/exports during the build.