Cloudflare Auto Minify breaks esbuild minified JS

We just ran into this issue in production and can confirm that it’s a current issue. The issue is explained in full in the esbuild repo here Cloudflare Minification breaks esbuild's "1 .toString" · Issue #3116 · evanw/esbuild · GitHub but in short, Cloudflare incorrectly removes whitespace from JS causing syntax errors in production.

e.g. esbuild outputs y=c(1 .toString) which is valid JS, Cloudflare minifies it to y=c(1.toString) (note that the space after the 1 has been removed).

We disabled the Auto Minify JS setting in Cloudflare for our production website and the problem went away.

We have resolved the issue ourselves but I wanted to add this to the community for SEO purposes as well as alerting Cloudflare to the issue.

2 Likes

We had the same problem