-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Description
Describe the bug
If a universal module/component imports server-only code...
<!-- +page.svelte -->
<script>
import { getRequestEvent } from '$app/server';
</script>
...you get this error at dev time:

It's annoying that you don't see the import chain until build
, and maybe we could fix that. But when you do build, you get this:

There's so much going on here:
- it's the same freaking error, which still says 'try building your app' to get a better error message
- it appears twice — once with a
[vite-plugin-sveltekit-compile] [vite-plugin-sveltekit-virtual-modules]
prefix, once with only a[vite-plugin-sveltekit-virtual-modules]
prefix. Huh? - it prints the entire file path, instead of one that's relative to your project folder (and hence much more readable)
- it includes a useless noisy stack trace
Separately: if a dependency in node_modules
illegally imports a server-only module, you don't find out until build time. Would be nice if there was a way to detect those a bit earlier, though IIUC Vite doesn't give us the necessary metadata. Something to worry about another time, I guess
Metadata
Metadata
Assignees
Labels
No labels