yuanyan / uglifyjs-java Goto Github PK
View Code? Open in Web Editor NEWJavaScript parser / mangler / compressor / beautifier library for for Java
Home Page: uglifyjs.madscript.com
JavaScript parser / mangler / compressor / beautifier library for for Java
Home Page: uglifyjs.madscript.com
Hi. Thanks for sharing this code, but can you explain how to compile the source into uglifyjs-java.jar? I don't see a pom.xml, and the build.xml seems to be for running the task, rather then compiling the .java files into a jar.
Thanks in advance.
"~/Sites/uglifyjs/test.js" is an UTF8 file and have non-ASCII characters. When I try to use UglifyJS-java like this:
java -jar uglifyjs-java.jar -nm -nc -o tmp/test.js ~/Sites/uglifyjs/test.js
It output error as:
Unexpected token name, expected punc | 5008 | 39 | 189814
javax.script.ScriptException: sun.org.mozilla.javascript.internal.JavaScriptException: [object Object](Unknown source>#274) in at line number 274
at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:153)
at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:167)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
at uglify.UglifyJS.exec(UglifyJS.java:53)
at uglify.UglifyJS.main(UglifyJS.java:16)
After I convert "~/Sites/uglifyjs/test.js" to GB18030, UglifyJS-java works well.
I couldn't make this run using JDK 8.0_131 (x64).
Here is the stack trace :
Exception in thread "main" java.lang.ArrayStoreException: jdk.nashorn.internal.runtime.Undefined
at jdk.nashorn.internal.runtime.arrays.ObjectArrayData.setEmpty(ObjectArrayData.java:161)
at jdk.nashorn.internal.runtime.arrays.ObjectArrayData.delete(ObjectArrayData.java:228)
at jdk.nashorn.internal.runtime.ScriptObject.delete(ScriptObject.java:3309)
at jdk.nashorn.internal.objects.NativeArray.shift(NativeArray.java:1170)
at jdk.nashorn.internal.scripts.Script$13$^eval_.:program(:32)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:449)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:406)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:402)
at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:150)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249)
at uglify.UglifyJS.run(UglifyJS.java:75)
at uglify.UglifyJS.exec(UglifyJS.java:50)
at uglify.ant.UglifyTask.execute(UglifyTask.java:237)
at uglify.ant.UglifyTask.main(UglifyTask.java:37)
I tried with an old JDK6u45 (x64) -> too old
I tried with JDK 7.0.40:
Ok if I run from main
Nok if I run from ant task (uglify is not defined):
[uglify] javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: Cannot modify a property of a sealed object: remove. (#12) in at line number 12
[uglify] Caused by: sun.org.mozilla.javascript.internal.EvaluatorException: Cannot modify a property of a sealed object: remove. (#12)
[uglify] javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "uglify" n'est pas défini (#1) in at line number 1
[uglify] Caused by: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "uglify" n'est pas défini (#1)
Correct me if I'm wrong.
Does this supports ES6 or any plan to support it in near future ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.