Worker custom webpack bundle doesn’t work properly with format=‘modules’

I try to build my worker using webpack. When i use service-worker syntax it bundles properly. But when i am trying to use an modules syntax i get an empty file and not able to run it. Can someone help me to setup configs properly?
4 Replies
Vlad
VladOP13mo ago
Cloudflare Community
Worker custom bundle doesn't work properly with format='modules'
I am trying to build my worker using webpack. When i use service-worker syntax it bundles properly. But when i am trying to use an modules syntax i get an empty file and not able to run it. Can someone help me to setup configs properly? My webpack configs are: module.exports = { target: 'webworker', entry: './src/worker.mjs', mode: 'produc...
Hello, I’m Allie!
wrangler automatically infers format now, if that is what you mean You don't tell it to use module syntax manually, it will just figure it out itself
Vlad
VladOP13mo ago
Okay, but it doesn't work anyway. I am getting empty build file if using module syntax. In other hand it is working when using service-worker syntax. Is there some config property i missed?
Hello, I’m Allie!
wrangler itself doesn't support Webpack builds at all anymore(unless you do it manually with a custom build, as you appear to be doing). If webpack isn't building correctly, then that is an issue with your webpack config.
Want results from more Discord servers?
Add your server