getting a few weird errors when trying
getting a few weird errors when trying to run this
the mentioned package
@hono/zod-validator
is installed and runs correctly when I run the worker via wrangler
has anyone run into something similar?22 Replies
here's a cleaner version of the error:
Hey! š Could you post your full terminal output from running the command?
If you could run with the
NODE_DEBUG=vitest-pool-workers:module-fallback
environment variable set, that would be great too. Although note this will generate a lot of output, so you might want to pipe it to a file.sure thing, one sec
Hmmm, that's interesting. It looks like
@hono/zod-validator
is being treated as a CommonJS module even though it's an ES module š
I'm guessing this is because it's trying to load a .js
file, but "type": "module"
isn't included the package.json
let me rip it out and try again
it's not super critical to use right now
was I just blind and couldn't see that error or how did you know that's the issue?
Yeah, looks like https://github.com/honojs/middleware/blob/main/packages/zod-validator/package.json doesn't include
"type": "module"
, but this is because the package exports both CommonJS and ES modules. I think the fix is for Hono to update their ES module version to use the .mjs
extension.cool, I'll let them know
Seen something similar before, this was the important part:
Essentially, a JavaScript file was failing to be parsed as CommonJS, which usually means it contains
import
/export
statements.aah ok
ok I removed the package now it crashes with the next hono package š
I guess that's as far as I'll get today, thank you so much
Oh dear ok. š
Thanks for letting them know though. š
do you know by chance if there's a way to override it locally?
I'd love to try out the vitest integration properly without waiting on them
I tried just adding type: module but the error remains
Hmmm, I think renaming the
dist/esm/*.js
files to dist/esm/*.mjs
and updating the package.json
to use the new *.mjs
files would work. Depending on how many packages you need to update, that might be a bit tedious though.just one or two
let me try, thank you
hmm, there's actually no dist/esm at all, so maybe it's a different issue š
Inside
@hono/zod-validator
? Or another package?it's looking in
/node_modules/.pnpm/...
but this is what actualyl exists:@hono/zod-validator
is missing from that directory entirely
or maybe I am misunderstanding how it should workAh those paths aren't quite correct. When
workerd
sends a request to the module fallback service, it resolves the specifier with the referrer directory. So import("@hono/zod-validator")
inside /a/b/c/index.mjs
would result in a request for /a/b/c/@hono/zod-validator
.
Because workerd
also sends the referrer, we're able to perform the reverse operation to get the actual specifier.š¤Æ you wizards, you š
then I'll continue my search here š
aand there's the
esm
šHi, having literally the same issue š
@chronark Did you find a way to fix it without modifying every hono's middleware ?
nope, I gave up for now :/
I raised it in hono's discord but that's pretty messy and I think it just got lost
Guess I'll give up,
zod-openapi
is broken as well
Test are overrated anyway š