-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix to avoid minification problem with esbuild #1368
base: master
Are you sure you want to change the base?
Conversation
esbuild will minify this to 1.toString (removing the zero) which will result in a syntax error in the browser.
esbuild actually minifies |
@@ -3,7 +3,7 @@ var uncurryThis = require('../internals/function-uncurry-this'); | |||
|
|||
var id = 0; | |||
var postfix = Math.random(); | |||
var toString = uncurryThis(1.0.toString); | |||
var toString = uncurryThis(1.1.toString); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bug on your minificator side. I already added some workarounds for such kind of parser / minificator bugs to this line (for example, 1..toString -> 1.0.toString)
, but I don't think we should encourage these bugs any further. I can accept this PR for compatibility with old versions of this tool (because it costs just 1 byte of compressed code), but only in case if this bug will be fixed in this tool itself.
@zloirock we use Vite (https://vite.dev/) which under the hood uses esbuild. We tried enforcing esbuid configs and nothing worked, we tried to use terser as minifyer but we got the same error as with esbuild. It makes sense that some tooling on the road will remove unecesary spaces in The fix I proposed here is just preventing using a zero It's funny how such a small and efficient fix is just rejected, this for sure would have prevented other people to run into this annoyance. Our only solution now is to have this ugly plugin for Vite that just pollutes every project we have that depends on core-js.
|
@diego-carvallo I'm curious: Did you miss my comment above? It's not a |
Here is the issue reported to ESBuild evanw/esbuild#3975 |
esbuild will minify this to 1.toString (removing the trailing zero) which will result in a syntax error in the browser. A trailing zero will be removed during minification but a trailing 1 wont.
See image below: