[GH-ISSUE #404] JavaScript Compression Fails #335

Closed
opened 2026-02-25 21:34:46 +03:00 by kerem · 5 comments
Owner

Originally created by @Master0ne on GitHub (Jun 7, 2020).
Original GitHub issue: https://github.com/cypht-org/cypht/issues/404

Originally assigned to: @jasonmunro on GitHub.

🐛 Bugreport

I have tried to apply JavaScript compression as per the js_compress config option in hm3.ini but it fails with the following error:

Using yuicompressor:

[ERROR] in -
  30:24:syntax error
[ERROR] in -
  1:0:Compilation produced 1 syntax errors.
org.mozilla.javascript.EvaluatorException: Compilation produced 1 syntax errors.
	at com.yahoo.platform.yui.compressor.YUICompressor$1.runtimeError(YUICompressor.java:172)
	at org.mozilla.javascript.Parser.parse(Parser.java:396)
	at org.mozilla.javascript.Parser.parse(Parser.java:340)
	at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:315)
	at com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>(JavaScriptCompressor.java:536)
	at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:147)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)
WARNING: Compression command failed: java -jar /path/to/yuicompressor-2.4.8.jar --type js

Using uglifyjs:

Parse error at 0:30,22
    return res.map(x => {return {name: x.name, value: decodeURIComponent(x.value
                      ^
ERROR: Unexpected token: operator «>»
    at JS_Parse_Error.get (eval at <anonymous> (/path/to/nodejs/lib/node_modules/uglify-js/tools/node.js:18:1), <anonymous>:69:23)
    at fatal (/path/to/nodejs/lib/node_modules/uglify-js/bin/uglifyjs:334:27)
    at run (/path/to/nodejs/lib/node_modules/uglify-js/bin/uglifyjs:277:9)
    at Socket.<anonymous> (/path/to/nodejs/lib/node_modules/uglify-js/bin/uglifyjs:200:9)
    at Socket.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1221:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
WARNING: Compression command failed: //path/to/uglifyjs -c --warn --verbose

Version & Environment

Rev: master
OS: Debian

Steps to reproduce

  1. Enable either yuicompressor or uglifyjs by js_compress= in hm3.ini
  2. Run scripts/config_gen.php
Originally created by @Master0ne on GitHub (Jun 7, 2020). Original GitHub issue: https://github.com/cypht-org/cypht/issues/404 Originally assigned to: @jasonmunro on GitHub. ## 🐛 Bugreport I have tried to apply JavaScript compression as per the `js_compress` config option in `hm3.ini` but it fails with the following error: Using `yuicompressor`: ```` [ERROR] in - 30:24:syntax error [ERROR] in - 1:0:Compilation produced 1 syntax errors. org.mozilla.javascript.EvaluatorException: Compilation produced 1 syntax errors. at com.yahoo.platform.yui.compressor.YUICompressor$1.runtimeError(YUICompressor.java:172) at org.mozilla.javascript.Parser.parse(Parser.java:396) at org.mozilla.javascript.Parser.parse(Parser.java:340) at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:315) at com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>(JavaScriptCompressor.java:536) at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:147) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21) WARNING: Compression command failed: java -jar /path/to/yuicompressor-2.4.8.jar --type js ```` Using `uglifyjs`: ```` Parse error at 0:30,22 return res.map(x => {return {name: x.name, value: decodeURIComponent(x.value ^ ERROR: Unexpected token: operator «>» at JS_Parse_Error.get (eval at <anonymous> (/path/to/nodejs/lib/node_modules/uglify-js/tools/node.js:18:1), <anonymous>:69:23) at fatal (/path/to/nodejs/lib/node_modules/uglify-js/bin/uglifyjs:334:27) at run (/path/to/nodejs/lib/node_modules/uglify-js/bin/uglifyjs:277:9) at Socket.<anonymous> (/path/to/nodejs/lib/node_modules/uglify-js/bin/uglifyjs:200:9) at Socket.emit (events.js:327:22) at endReadableNT (_stream_readable.js:1221:12) at processTicksAndRejections (internal/process/task_queues.js:84:21) WARNING: Compression command failed: //path/to/uglifyjs -c --warn --verbose ```` ### Version & Environment Rev: master OS: Debian ### Steps to reproduce 1. Enable either `yuicompressor` or `uglifyjs` by `js_compress=` in `hm3.ini` 2. Run `scripts/config_gen.php`
kerem 2026-02-25 21:34:46 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@jasonmunro commented on GitHub (Jun 10, 2020):

Sadly you now need to use an ES6 compatible compression tool so yuicompressor or uglifyjs won't work anymore. However uglifyjs.terser should work fine. I will update the sample ini with more accurate examples.

<!-- gh-comment-id:642132678 --> @jasonmunro commented on GitHub (Jun 10, 2020): Sadly you now need to use an ES6 compatible compression tool so yuicompressor or uglifyjs won't work anymore. However uglifyjs.terser should work fine. I will update the sample ini with more accurate examples.
Author
Owner

@Master0ne commented on GitHub (Jun 10, 2020):

Very well, I'll give uglifyjs.terser a try then.

<!-- gh-comment-id:642161077 --> @Master0ne commented on GitHub (Jun 10, 2020): Very well, I'll give `uglifyjs.terser` a try then.
Author
Owner

@Master0ne commented on GitHub (Jun 11, 2020):

@jasonmunro I have now installed terser v4.7.0

Can you please let me know which command line parameters to pass in hm3.ini?

<!-- gh-comment-id:642407041 --> @Master0ne commented on GitHub (Jun 11, 2020): @jasonmunro I have now installed [terser](https://www.npmjs.com/package/terser) v4.7.0 Can you please let me know which command line parameters to pass in `hm3.ini`?
Author
Owner

@jasonmunro commented on GitHub (Jun 11, 2020):

I have the following:

js_compress='uglifyjs.terser -c -m --verbose --warn'

<!-- gh-comment-id:642804092 --> @jasonmunro commented on GitHub (Jun 11, 2020): I have the following: `js_compress='uglifyjs.terser -c -m --verbose --warn'`
Author
Owner

@jasonmunro commented on GitHub (Jun 25, 2020):

Sample ini file updated with a current example so I'm closing this. Thanks for the feedback!

<!-- gh-comment-id:649764714 --> @jasonmunro commented on GitHub (Jun 25, 2020): Sample ini file updated with a current example so I'm closing this. Thanks for the feedback!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cypht#335
No description provided.