Vite pulls in wrong file for Zod #2638
websocket98765
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When importing Zod into a Svelte Kit project, Vite attempts to import a typescript file, for an unknown reason. The author of Zod confirmed this should not be happening, it should use Zod's JavaScript entry point.
Error
The error is
ENOENT: no such file or directory, open '/Users/me/my-app/node_modules/zod/src/index.ts'
. But Zod actually exports JavaScript as both CJS and ESM.Zod was imported via:
import * as z from 'zod';
Original error report to Zod:
colinhacks/zod#168 (comment)
Reproduce
To reproduce, create a svelte kit project
Then in index.svelte, add this import
import * as z from 'zod';
, and save. It should cause an error in the dev server console.Info
Vite: ^2.1.0
@sveltejs/kit: next
zod: ^3.0.0-alpha.24
Node: v14.7.0
MacOS
Beta Was this translation helpful? Give feedback.
All reactions