[Pkg-javascript-commits] [uglifyjs] 22/77: Support keep_fnames in compressor, and --keep-fnames. #552
Jonas Smedegaard
dr at jones.dk
Tue May 19 00:02:28 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag v2.4.18
in repository uglifyjs.
commit e1f0747e4cca7b77a0189dacbff9fa4800a2835c
Author: Mihai Bazon <mihai at bazon.net>
Date: Mon Jan 5 11:03:13 2015 +0200
Support keep_fnames in compressor, and --keep-fnames. #552
Passing `--keep-fnames` will enable it both for compressor/mangler, so that
function names will not be dropped (when unused) nor mangled.
---
bin/uglifyjs | 6 ++++++
lib/compress.js | 3 ++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/bin/uglifyjs b/bin/uglifyjs
index a177cb6..44afd2f 100755
--- a/bin/uglifyjs
+++ b/bin/uglifyjs
@@ -65,6 +65,7 @@ You need to pass an argument to this option to specify the name that your module
.describe("V", "Print version number and exit.")
.describe("noerr", "Don't throw an error for unknown options in -c, -b or -m.")
.describe("bare-returns", "Allow return outside of functions. Useful when minifying CommonJS modules.")
+ .describe("keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name.")
.alias("p", "prefix")
.alias("o", "output")
@@ -160,6 +161,11 @@ if (ARGS.screw_ie8) {
OUTPUT_OPTIONS.screw_ie8 = true;
}
+if (ARGS.keep_fnames) {
+ if (COMPRESS) COMPRESS.keep_fnames = true;
+ if (MANGLE) MANGLE.keep_fnames = true;
+}
+
if (BEAUTIFY)
UglifyJS.merge(OUTPUT_OPTIONS, BEAUTIFY);
diff --git a/lib/compress.js b/lib/compress.js
index 2c95099..345d8ad 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -62,6 +62,7 @@ function Compressor(options, false_by_default) {
unused : !false_by_default,
hoist_funs : !false_by_default,
keep_fargs : false,
+ keep_fnames : false,
hoist_vars : false,
if_return : !false_by_default,
join_vars : !false_by_default,
@@ -1666,7 +1667,7 @@ merge(Compressor.prototype, {
OPT(AST_Function, function(self, compressor){
self = AST_Lambda.prototype.optimize.call(self, compressor);
- if (compressor.option("unused")) {
+ if (compressor.option("unused") && !compressor.option("keep_fnames")) {
if (self.name && self.name.unreferenced()) {
self.name = null;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git
More information about the Pkg-javascript-commits
mailing list