Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SvelteKit - Named export 'SWR' not found #37

Closed
mikenikles opened this issue Aug 27, 2022 · 3 comments
Closed

SvelteKit - Named export 'SWR' not found #37

mikenikles opened this issue Aug 27, 2022 · 3 comments

Comments

@mikenikles
Copy link

I use sswr in a SvelteKit application ("@sveltejs/kit": "^1.0.0-next.442").

In dev, everything works fine. However, when I run npm run build and npm run preview and load a page that imports sswr, I see the following error:

SyntaxError: Named export 'SWR' not found. The requested module 'swrev' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'swrev';
const { SWR } = pkg;

Does anyone have a working example of sswr with SvelteKit? Maybe @khromov because of #34 🤔?

@ConsoleTVs
Copy link
Owner

ConsoleTVs commented Aug 27, 2022

Ah yeah, because vite 3 outputs and expects .mjs modules instead of .esm.js. I noticed that too. The fix is update this lib to vite 3 and change the pkg exports. Will do.

@arunrddy
Copy link

Vite CommonJS Plugin might get this working.

@ConsoleTVs
Copy link
Owner

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants