Wrangler compiling in an incompatible way?
As mentioned here https://discord.com/channels/595317990191398933/846453104382836766/1079084350437589063
I'm using wrangler to publish a worker, but there seems to be a bug.
In my code
index.ts
I export default like so
When using wrangler publish
it compiles to:
And in the dashboard when I try to test it it tells me
Though when I change it manually to the former again:
It seems to work and goes to the next error about a constructor.
Changing the tsconfig.json
file doesn't seem to make any difference at all.
Looks like a bug to me. Any ideas of what I can try?7 Replies
Feel free to explore the code and configuration here: https://github.com/webbertakken/email-worker
GitHub
GitHub - webbertakken/email-worker: Lightweight tool to process ema...
Lightweight tool to process emails directly from Cloudflare - GitHub - webbertakken/email-worker: Lightweight tool to process emails directly from Cloudflare
I can reproduce it using Wrangler
2.7.1
, 2.11.0
and 2.11.1
.Even compiling a console.log only shows the same behaviour:
If only it compiled to
It would simply work (note the
default
part).
Also tried using this template https://github.com/cloudflare/miniflare-typescript-esbuild-jest which uses ESBuild.
I've added a minimal method like so:
Which has exactly the same result. Definitely looks like something is broken on CF side
I've also tried Vercel NCC, which uses Webpack. Same result.i'm not familiar with email workers and stuff, but writing
instead of
should make no difference as it's exactly the same, just with a little different syntax.
Agreed. The operative word here being "should". That's why I mentioned it's likely a bug.
TL;DR: After a lot of debugging I've managed to get a fully working email worker.
https://github.com/webbertakken/email-worker
Note that even though the worker is fully functional, the dashboard view of email workers is still bugged.
The only thing that solves that issue is to manually change from
to
I'm really hoping this helps CF easily solve this issue. Or at least helps other people facing the same problem wasting a lot less time by reading this.
GitHub
GitHub - webbertakken/email-worker: Lightweight tool to process ema...
Lightweight tool to process emails directly from Cloudflare - GitHub - webbertakken/email-worker: Lightweight tool to process emails directly from Cloudflare