Webpack. No event handlers were registered. This script does nothing.

I have prepared webpack.config.js
....
output: {
filename: "worker.js",
path: path.resolve(__dirname, "dist"),
library: 'webpack-test',
libraryTarget: 'commonjs2'

and receive webpack result in dist folder. Then I try to load this result to Cloudflare “wrangler deploy” with setup in TOML file of webpack result

...
main = "./dist/worker.js"

And receive this strange result

⛅️ wrangler 3.36.0
-------------------
Total Upload: 2.21 KiB / gzip: 0.96 KiB
X [ERROR] A request to the Cloudflare API (/accounts/879d75a301cfdc25c307469b83b91862/workers/scripts/webpack) failed.
No event handlers were registered. This script does nothing.
[code: 10021]

Why? What I done wrong? Or Webpack not applicable to Worker at all?
Was this page helpful?