Skip to content
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

JS minify error: too many nested expressions #451

Closed
jmooring opened this issue Jan 13, 2022 · 8 comments
Closed

JS minify error: too many nested expressions #451

jmooring opened this issue Jan 13, 2022 · 8 comments

Comments

@jmooring
Copy link
Contributor

jmooring commented Jan 13, 2022

Tested with v2.9.27.

too many nested expressions on line 1 and column 137156
    1: ...}(t,e))),Xe()}var o},Js.prototype.invoke_...
                              ^

test.js.txt

Reference:
https://discourse.gohugo.io/t/build-failure-with-0-92/36523

@jmooring
Copy link
Contributor Author

This appears to be a regression introduced in v2.9.17.

@tdewolff
Copy link
Owner

Thanks Joe, I'm on it!

@tdewolff
Copy link
Owner

Looks like it is not so much a bug, but a hard limit to prevent abuse. The problem is that the file in question has an expression of comma-operators that has more than 1000 elements (ie. a,b,c,d,...,AA,BB of length 1000). Since this creates a tree of a 1000 branches and leaves, that is fairly inefficient (which is why the limit is there in the first place, to prevent memory trouble).

The solution is to parse comma-operators as a list and not a tree.

@tdewolff
Copy link
Owner

Should be fixed now, please advice if you run into additional problems

@jmooring
Copy link
Contributor Author

Thanks!

@ylazy
Copy link

ylazy commented Nov 5, 2024

@tdewolff I'm facing this issue in the latest release (2.21.1):

Error minimizing index.js:
minify.exe --css-precision 0 --html-keep-conditional-comments --html-keep-default-attrvals --html-keep-document-tags --html-keep-end-tags --html-keep-quotes --html-keep-special-comments --js-keep-var-names --js-precision 0 --json-keep-numbers --json-precision 0 --svg-precision 0 --output "C:\Users\admin\Downloads\2000x1200\index.min.js" "index.js"
ERROR: cannot minify index.js: too many nested expressions on line 678 and column 15528
  678: ...y:162.2156}).wait(1).to({graphics:mask_gr...

index.zip

Please check this!
Thank you!

@tdewolff
Copy link
Owner

tdewolff commented Nov 5, 2024

That is a huge concatenation of member operators (dot operators). I don't think this could be fixed like we did with the comma operator. But perhaps we could make the ExprLimit a variable you can change. Let me see if I can get this in this week.

@tdewolff
Copy link
Owner

I've added this in the parse package and should soon be used in minify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants