ESM module in Zod 2 beta causing runtime error
See original GitHub issueWith Zod 2.0.0-beta.20:
With Zod 1.11, no error.
Only seems to happen when using the object type
// no crash
z.string();
z.date();
// crashes
z.object({});
z.object({
id: z.string(),
});
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
ESM in .mjs files cause a dev mode runtime error · Issue #17806
Importing a project ESM .mjs file (the Node.js standard file extension for ESM) in a page file causes a runtime error, but only...
Read more >require() of ES modules is not supported when importing node ...
js file has nothing but the import of node-fetch and it gives me an error message. What am I doing wrong? Running Ubuntu...
Read more >module-not-found - Next.js
A module not found error can occur for many different reasons: The module you're trying to import is not installed in your dependencies;...
Read more >Announcing TypeScript 4.7 RC - Microsoft Developer Blogs
In our beta release, we announced a stable target for our Node ESM support ... TypeScript 4.7 adds this functionality with two new...
Read more >Colin McDonnell on Twitter: "Zod 3.0 has landed!! ❤️ It only ...
Zod 3.0 has landed!! ❤️ It only took a measly 8 months, 44 prereleases, and 446 commits! ☕️ ESM modules Deno...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Gonna re-open because the root problem here isn’t solved 😦
I removed the ESM module in
zod@2.0.0-beta.21
. If you upgrade your builds should work again.I’ve also reproduced this issue. Now that I’m aware of this I’ll be able to guarantee ESM compatibility before trying to ship an ESM module again. It’s not trivial to fix so it’ll take some time. There are certain internal circular imports inside Zod’s source code that work fine with CommonJS modules but not with ESM.