google-code-export / wro4j

Automatically exported from code.google.com/p/wro4j
1 stars 1 forks source link

beautifyJs mangling local variables #801

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Write some js code that uses local variables.
2. Use the wro4j "beautifyJs" processor.

What is the expected output? What do you see instead?
Expected beatification to just strip comments and format the code.
Instead, the local variable names are replaced with single letter alternatives.

What version of the product are you using? On what operating system?
wro4j 1.7. Windows.

Please provide any additional information below.

Original issue reported on code.google.com by easle...@gmail.com on 15 Oct 2013 at 11:19

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Alternatively, can a js processor be supplied that just removes comments? This 
would actually suit be better, and I imagine it would be a lot faster. Note: 
I'm using wro4j as a build-time solution (via wro4j-runner).

Original comment by easle...@gmail.com on 15 Oct 2013 at 11:23

GoogleCodeExporter commented 9 years ago
The beautifyJs processor uses a javascript library which performs the actual 
transformation. I'm afraid it is not possible to avoid replacement with single 
letter unless the js library can be configured in the such way.

Regarding the comment removal, there is MultiLineCommentStripperProcessor with 
alias "multilineStripper" which can be used to remove multiline comments. 

Original comment by alex.obj...@gmail.com on 15 Oct 2013 at 11:27

GoogleCodeExporter commented 9 years ago
The js library is uglifyJs, if I've read the code correctly. I believe this can 
be configured to not mangle. Surely that would include not mangling local 
variables.

Original comment by easle...@gmail.com on 15 Oct 2013 at 12:21

GoogleCodeExporter commented 9 years ago
Thanks for this "multilineStripper" tip.
Does this include 

// comments
// like this,

/*
 * Or just comments like this?
 */

Original comment by easle...@gmail.com on 15 Oct 2013 at 12:23

GoogleCodeExporter commented 9 years ago
It removes multiline comments only. For singleline comment, there is 
SingleLineCommentStripperProcessor, but it doesn't have an alias associated. 
I'll add it for the next release.

Original comment by alex.obj...@gmail.com on 15 Oct 2013 at 12:37