-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Using esbuild minifier breaks code #2139
Comments
This could be caused by minify-syntax. You can turn it off by adding options to the rollup plugin: minify({
minify: false,
minifyWhitespace: true,
minifyIdentifiers: true,
}) However it is hard to tell what's wrong in the minified code, Update: I've tried some older versions of esbuild (from 0.10.1, since the rollup plugin specified that version range) and there's no luck. Update2: I've noticed gojs' latest version 2.2.5 (current 1.8.38), just tried upgrade that package and now it all works. The oldest working version most close to 1.8.38 is 2.0.2. |
Thanks for the report. I've traced it down to this optimization: esbuild/internal/js_parser/js_parser.go Lines 9219 to 9221 in 2244c09
The issue is with if statements of the following form: if (a)
b: {
if (c) {
break b
}
}
else if (d)
e() That code is incorrectly minified into this: if (a)
b:
if (c)
break b;
else
d && e(); The problem is that the AST printer doesn't add braces to avoid the inner if (a) {
b:
if (c)
break b;
} else
d && e(); |
We are using 1.8.38 version of gojs library and the library(which is valid javascript code) breaks after minification with esbuild.
Here is repo that can be used to reproduce the issue. Instructions to build and run code can be found in the README file in the repo.
https://github.com/surgicaI/esbuild-gojs-minify-bug
In the above repo, rollup is used to generate javascript bundle from source code and rollup config can be found here. Gojs library is used to create diagrams and notice that when the generated javascript bundle is minified using
minify
module from esbuild, the code breaks and no diagram is rendered in the app.Please look into the issue
The text was updated successfully, but these errors were encountered: