Skip to content

Commit 16f0761

Browse files
committed
Fixes requirejs#207, include uglify 1.3.2
1 parent 862769e commit 16f0761

File tree

6 files changed

+43
-14
lines changed

6 files changed

+43
-14
lines changed

build/jslib/uglifyjs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
This is a copy of UglifyJS from:
22
https://github.com/mishoo/UglifyJS
33

4-
Using "1.3.0", from npm. Check github tags and npm to find the latest version.
4+
Using "1.3.2", from npm. Check github tags and npm to find the latest version.
55

66
UglifyJS is under the BSD license, and it a third-party package.
77

build/jslib/uglifyjs/consolidator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1218,4 +1218,4 @@ exports['ast_consolidate'] = function(oAbstractSyntaxTree) {
12181218
/* End: */
12191219
/* vim: set ft=javascript fenc=utf-8 et ts=2 sts=2 sw=2: */
12201220
/* :mode=javascript:noTabs=true:tabSize=2:indentSize=2:deepIndent=true: */
1221-
});
1221+
});

build/jslib/uglifyjs/parse-js.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,9 @@ exports.KEYWORDS = KEYWORDS;
13581358
exports.ATOMIC_START_TOKEN = ATOMIC_START_TOKEN;
13591359
exports.OPERATORS = OPERATORS;
13601360
exports.is_alphanumeric_char = is_alphanumeric_char;
1361+
exports.is_identifier_start = is_identifier_start;
1362+
exports.is_identifier_char = is_identifier_char;
13611363
exports.set_logger = function(logger) {
13621364
warn = logger;
13631365
};
1364-
});
1366+
});

build/jslib/uglifyjs/process.js

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
define(["require", "exports", "module", "./parse-js", "./squeeze-more"], function(require, exports, module) {
2+
23
/***********************************************************************
34
45
A JavaScript tokenizer / parser / beautifier / compressor.
@@ -62,6 +63,7 @@ define(["require", "exports", "module", "./parse-js", "./squeeze-more"], functio
6263
var jsp = require("./parse-js"),
6364
slice = jsp.slice,
6465
member = jsp.member,
66+
is_identifier_char = jsp.is_identifier_char,
6567
PRECEDENCE = jsp.PRECEDENCE,
6668
OPERATORS = jsp.OPERATORS;
6769

@@ -510,7 +512,13 @@ function ast_add_scope(ast) {
510512

511513
function ast_mangle(ast, options) {
512514
var w = ast_walker(), walk = w.walk, scope;
513-
options = options || {};
515+
options = defaults(options, {
516+
mangle : true,
517+
toplevel : false,
518+
defines : null,
519+
except : null,
520+
no_functions : false
521+
});
514522

515523
function get_mangled(name, newMangle) {
516524
if (!options.mangle) return name;
@@ -537,7 +545,7 @@ function ast_mangle(ast, options) {
537545
};
538546

539547
function _lambda(name, args, body) {
540-
if (!options.no_functions) {
548+
if (!options.no_functions && options.mangle) {
541549
var is_defun = this[0] == "defun", extra;
542550
if (name) {
543551
if (is_defun) name = get_mangled(name);
@@ -1237,6 +1245,9 @@ function ast_squeeze(ast, options) {
12371245
t = walk(t);
12381246
e = walk(e);
12391247

1248+
if (empty(e) && empty(t))
1249+
return [ "stat", c ];
1250+
12401251
if (empty(t)) {
12411252
c = negate(c);
12421253
t = e;
@@ -1257,8 +1268,6 @@ function ast_squeeze(ast, options) {
12571268
}
12581269
})();
12591270
}
1260-
if (empty(e) && empty(t))
1261-
return [ "stat", c ];
12621271
var ret = [ "if", c, t, e ];
12631272
if (t[0] == "if" && empty(t[3]) && empty(e)) {
12641273
ret = best_of(ret, walk([ "if", [ "binary", "&&", c, t[1] ], t[2] ]));
@@ -1402,6 +1411,15 @@ function ast_squeeze(ast, options) {
14021411
return expr[1];
14031412
}
14041413
return [ this[0], expr, MAP(args, walk) ];
1414+
},
1415+
"num": function (num) {
1416+
if (!isFinite(num))
1417+
return [ "binary", "/", num === 1 / 0
1418+
? [ "num", 1 ] : num === -1 / 0
1419+
? [ "unary-prefix", "-", [ "num", 1 ] ]
1420+
: [ "num", 0 ], [ "num", 0 ] ];
1421+
1422+
return [ this[0], num ];
14051423
}
14061424
}, function() {
14071425
for (var i = 0; i < 2; ++i) {
@@ -1502,6 +1520,15 @@ function gen_code(ast, options) {
15021520
finally { indentation -= incr; }
15031521
};
15041522

1523+
function last_char(str) {
1524+
str = str.toString();
1525+
return str.charAt(str.length - 1);
1526+
};
1527+
1528+
function first_char(str) {
1529+
return str.toString().charAt(0);
1530+
};
1531+
15051532
function add_spaces(a) {
15061533
if (beautify)
15071534
return a.join(" ");
@@ -1510,7 +1537,8 @@ function gen_code(ast, options) {
15101537
var next = a[i + 1];
15111538
b.push(a[i]);
15121539
if (next &&
1513-
((/[a-z0-9_\x24]$/i.test(a[i].toString()) && /^[a-z0-9_\x24]/i.test(next.toString())) ||
1540+
((is_identifier_char(last_char(a[i])) && (is_identifier_char(first_char(next))
1541+
|| first_char(next) == "\\")) ||
15141542
(/[\+\-]$/.test(a[i].toString()) && /^[\+\-]/.test(next.toString())))) {
15151543
b.push(" ");
15161544
}
@@ -1570,7 +1598,7 @@ function gen_code(ast, options) {
15701598
};
15711599

15721600
function make_num(num) {
1573-
var str = num.toString(10), a = [ str.replace(/^0\./, ".") ], m;
1601+
var str = num.toString(10), a = [ str.replace(/^0\./, ".").replace('e+', 'e') ], m;
15741602
if (Math.floor(num) === num) {
15751603
if (num >= 0) {
15761604
a.push("0x" + num.toString(16).toLowerCase(), // probably pointless
@@ -2063,4 +2091,4 @@ exports.MAP = MAP;
20632091

20642092
// keep this last!
20652093
exports.ast_squeeze_more = require("./squeeze-more").ast_squeeze_more;
2066-
});
2094+
});

build/jslib/uglifyjs/squeeze-more.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
define(["require", "exports", "module", "./parse-js", "./process"], function(require, exports, module) {
2-
3-
var jsp = require("./parse-js"),
2+
var jsp = require("./parse-js"),
43
pro = require("./process"),
54
slice = jsp.slice,
65
member = jsp.member,
@@ -74,4 +73,4 @@ function ast_squeeze_more(ast) {
7473
};
7574

7675
exports.ast_squeeze_more = ast_squeeze_more;
77-
});
76+
});

tests/node/embedded/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var cs = require('coffee-script'),
2-
requirejs = require('requirejs');
2+
requirejs = require('../../../dist/r.js');
33

44
requirejs.config({
55
baseUrl: 'scripts',

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy