11/**
2- * @license r.js 2.3.2+ Thu, 16 Feb 2017 06:56:59 GMT Copyright jQuery Foundation and other contributors.
2+ * @license r.js 2.3.2+ Sun, 19 Feb 2017 00:43:50 GMT Copyright jQuery Foundation and other contributors.
33 * Released under MIT license, http://github.com/requirejs/r.js/LICENSE
44 */
55
@@ -19,7 +19,7 @@ var requirejs, require, define, xpcUtil;
1919(function (console, args, readFileFunc) {
2020 var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
2121 nodeDefine, exists, reqMain, loadedOptimizedLib, existsForNode, Cc, Ci,
22- version = '2.3.2+ Thu, 16 Feb 2017 06:56:59 GMT',
22+ version = '2.3.2+ Sun, 19 Feb 2017 00:43:50 GMT',
2323 jsSuffixRegExp = /\.js$/,
2424 commandOption = '',
2525 useLibLoaded = {},
@@ -14053,6 +14053,8 @@ function merge(obj, ext) {
1405314053};
1405414054
1405514055function noop() {};
14056+ function return_false() { return false; }
14057+ function return_true() { return true; }
1405614058
1405714059var MAP = (function(){
1405814060 function MAP(a, f, backwards) {
@@ -17767,6 +17769,20 @@ AST_Toplevel.DEFMETHOD("scope_warnings", function(options){
1776717769
1776817770var EXPECT_DIRECTIVE = /^$|[;{][\s\n]*$/;
1776917771
17772+ function is_some_comments(comment) {
17773+ var text = comment.value;
17774+ var type = comment.type;
17775+ if (type == "comment2") {
17776+ // multiline comment
17777+ return /@preserve|@license|@cc_on/i.test(text);
17778+ }
17779+ return type == "comment5";
17780+ }
17781+
17782+ function is_comment5(comment) {
17783+ return comment.type == "comment5";
17784+ }
17785+
1777017786function OutputStream(options) {
1777117787
1777217788 options = defaults(options, {
@@ -17790,50 +17806,34 @@ function OutputStream(options) {
1779017806 preamble : null,
1779117807 quote_style : 0,
1779217808 keep_quoted_props: false,
17793- wrap_iife : false
17809+ wrap_iife : false,
1779417810 }, true);
1779517811
1779617812 // Convert comment option to RegExp if neccessary and set up comments filter
17797- if (typeof options.comments === "string" && /^\/.*\/[a-zA-Z]*$/.test(options.comments)) {
17798- var regex_pos = options.comments.lastIndexOf("/");
17799- options.comments = new RegExp(
17800- options.comments.substr(1, regex_pos - 1),
17801- options.comments.substr(regex_pos + 1)
17802- );
17803- }
17804- if (options.comments instanceof RegExp) {
17805- options.comments = (function(f) {
17806- return function(comment) {
17807- return comment.type == "comment5" || f.test(comment.value);
17808- }
17809- })(options.comments);
17810- }
17811- else if (typeof options.comments === "function") {
17812- options.comments = (function(f) {
17813- return function(comment) {
17814- return comment.type == "comment5" || f(this, comment);
17815- }
17816- })(options.comments);
17817- }
17818- else if (options.comments === "some") {
17819- options.comments = function(comment) {
17820- var text = comment.value;
17821- var type = comment.type;
17822- if (type == "comment2") {
17823- // multiline comment
17824- return /@preserve|@license|@cc_on/i.test(text);
17825- }
17826- return type == "comment5";
17813+ var comment_filter = options.shebang ? is_comment5 : return_false; // Default case, throw all comments away except shebangs
17814+ if (options.comments) {
17815+ var comments = options.comments;
17816+ if (typeof options.comments === "string" && /^\/.*\/[a-zA-Z]*$/.test(options.comments)) {
17817+ var regex_pos = options.comments.lastIndexOf("/");
17818+ comments = new RegExp(
17819+ options.comments.substr(1, regex_pos - 1),
17820+ options.comments.substr(regex_pos + 1)
17821+ );
1782717822 }
17828- }
17829- else if (options.comments){ // NOTE includes "all" option
17830- options.comments = function() {
17831- return true ;
17823+ if (comments instanceof RegExp) {
17824+ comment_filter = function(comment) {
17825+ return comment.type == "comment5" || comments.test(comment.value);
17826+ } ;
1783217827 }
17833- } else {
17834- // Falsy case, so reject all comments, except shebangs
17835- options.comments = function(comment) {
17836- return comment.type == "comment5";
17828+ else if (typeof comments === "function") {
17829+ comment_filter = function(comment) {
17830+ return comment.type == "comment5" || comments(this, comment);
17831+ };
17832+ }
17833+ else if (comments === "some") {
17834+ comment_filter = is_some_comments;
17835+ } else { // NOTE includes "all" option
17836+ comment_filter = return_true;
1783717837 }
1783817838 }
1783917839
@@ -18143,6 +18143,7 @@ function OutputStream(options) {
1814318143 with_square : with_square,
1814418144 add_mapping : add_mapping,
1814518145 option : function(opt) { return options[opt] },
18146+ comment_filter : comment_filter,
1814618147 line : function() { return current_line },
1814718148 col : function() { return current_col },
1814818149 pos : function() { return current_pos },
@@ -18225,7 +18226,7 @@ function OutputStream(options) {
1822518226 }));
1822618227 }
1822718228
18228- comments = comments.filter(output.option("comments") , self);
18229+ comments = comments.filter(output.comment_filter , self);
1822918230
1823018231 // Keep single line comments after nlb, after nlb
1823118232 if (!output.option("beautify") && comments.length > 0 &&
@@ -20098,7 +20099,7 @@ merge(Compressor.prototype, {
2009820099 (function (def){
2009920100 var unary_bool = [ "!", "delete" ];
2010020101 var binary_bool = [ "in", "instanceof", "==", "!=", "===", "!==", "<", "<=", ">=", ">" ];
20101- def(AST_Node, function(){ return false } );
20102+ def(AST_Node, return_false );
2010220103 def(AST_UnaryPrefix, function(){
2010320104 return member(this.operator, unary_bool);
2010420105 });
@@ -20116,16 +20117,16 @@ merge(Compressor.prototype, {
2011620117 def(AST_Seq, function(){
2011720118 return this.cdr.is_boolean();
2011820119 });
20119- def(AST_True, function(){ return true } );
20120- def(AST_False, function(){ return true } );
20120+ def(AST_True, return_true );
20121+ def(AST_False, return_true );
2012120122 })(function(node, func){
2012220123 node.DEFMETHOD("is_boolean", func);
2012320124 });
2012420125
2012520126 // methods to determine if an expression has a string result type
2012620127 (function (def){
20127- def(AST_Node, function(){ return false } );
20128- def(AST_String, function(){ return true } );
20128+ def(AST_Node, return_false );
20129+ def(AST_String, return_true );
2012920130 def(AST_UnaryPrefix, function(){
2013020131 return this.operator == "typeof";
2013120132 });
@@ -20379,11 +20380,11 @@ merge(Compressor.prototype, {
2037920380
2038020381 // determine if expression has side effects
2038120382 (function(def){
20382- def(AST_Node, function(compressor){ return true } );
20383+ def(AST_Node, return_true );
2038320384
20384- def(AST_EmptyStatement, function(compressor){ return false } );
20385- def(AST_Constant, function(compressor){ return false } );
20386- def(AST_This, function(compressor){ return false } );
20385+ def(AST_EmptyStatement, return_false );
20386+ def(AST_Constant, return_false );
20387+ def(AST_This, return_false );
2038720388
2038820389 def(AST_Call, function(compressor){
2038920390 var pure = compressor.option("pure_funcs");
@@ -20403,13 +20404,13 @@ merge(Compressor.prototype, {
2040320404 def(AST_SimpleStatement, function(compressor){
2040420405 return this.body.has_side_effects(compressor);
2040520406 });
20406- def(AST_Defun, function(compressor){ return true } );
20407- def(AST_Function, function(compressor){ return false } );
20407+ def(AST_Defun, return_true );
20408+ def(AST_Function, return_false );
2040820409 def(AST_Binary, function(compressor){
2040920410 return this.left.has_side_effects(compressor)
2041020411 || this.right.has_side_effects(compressor);
2041120412 });
20412- def(AST_Assign, function(compressor){ return true } );
20413+ def(AST_Assign, return_true );
2041320414 def(AST_Conditional, function(compressor){
2041420415 return this.condition.has_side_effects(compressor)
2041520416 || this.consequent.has_side_effects(compressor)
@@ -22172,7 +22173,7 @@ function SourceMap(options) {
2217222173 var orig_map = options.orig && new MOZ_SourceMap.SourceMapConsumer(options.orig);
2217322174
2217422175 if (orig_map && Array.isArray(options.orig.sources)) {
22175- options.orig.sources .forEach(function(source) {
22176+ orig_map._sources.toArray() .forEach(function(source) {
2217622177 var sourceContent = orig_map.sourceContentFor(source, true);
2217722178 if (sourceContent) {
2217822179 generator.setSourceContent(source, sourceContent);
@@ -22886,7 +22887,8 @@ function mangle_properties(ast, options) {
2288622887 cache : null,
2288722888 only_cache : false,
2288822889 regex : null,
22889- ignore_quoted : false
22890+ ignore_quoted : false,
22891+ debug : false
2289022892 });
2289122893
2289222894 var reserved = options.reserved;
@@ -22904,6 +22906,15 @@ function mangle_properties(ast, options) {
2290422906 var regex = options.regex;
2290522907 var ignore_quoted = options.ignore_quoted;
2290622908
22909+ // note debug is either false (disabled), or a string of the debug suffix to use (enabled).
22910+ // note debug may be enabled as an empty string, which is falsey. Also treat passing 'true'
22911+ // the same as passing an empty string.
22912+ var debug = (options.debug !== false);
22913+ var debug_name_suffix;
22914+ if (debug) {
22915+ debug_name_suffix = (options.debug === true ? "" : options.debug);
22916+ }
22917+
2290722918 var names_to_mangle = [];
2290822919 var unmangleable = [];
2290922920 var ignored = {};
@@ -22997,9 +23008,25 @@ function mangle_properties(ast, options) {
2299723008
2299823009 var mangled = cache.props.get(name);
2299923010 if (!mangled) {
23000- do {
23001- mangled = base54(++cache.cname);
23002- } while (!can_mangle(mangled));
23011+ if (debug) {
23012+ // debug mode: use a prefix and suffix to preserve readability, e.g. o.foo -> o._$foo$NNN_.
23013+ var debug_mangled = "_$" + name + "$" + debug_name_suffix + "_";
23014+
23015+ if (can_mangle(debug_mangled) && !(ignore_quoted && debug_mangled in ignored)) {
23016+ mangled = debug_mangled;
23017+ }
23018+ }
23019+
23020+ // either debug mode is off, or it is on and we could not use the mangled name
23021+ if (!mangled) {
23022+ // note can_mangle() does not check if the name collides with the 'ignored' set
23023+ // (filled with quoted properties when ignore_quoted set). Make sure we add this
23024+ // check so we don't collide with a quoted name.
23025+ do {
23026+ mangled = base54(++cache.cname);
23027+ } while (!can_mangle(mangled) || (ignore_quoted && mangled in ignored));
23028+ }
23029+
2300323030 cache.props.set(name, mangled);
2300423031 }
2300523032 return mangled;
@@ -23054,6 +23081,7 @@ exports.minify = function(files, options, name) {
2305423081 options = defaults(options, {
2305523082 spidermonkey : false,
2305623083 outSourceMap : null,
23084+ outFileName : null,
2305723085 sourceRoot : null,
2305823086 inSourceMap : null,
2305923087 sourceMapUrl : null,
@@ -23133,7 +23161,8 @@ exports.minify = function(files, options, name) {
2313323161 }
2313423162 if (options.outSourceMap || options.sourceMapInline) {
2313523163 output.source_map = SourceMap({
23136- file: options.outSourceMap,
23164+ // prefer outFileName, otherwise use outSourceMap without .map suffix
23165+ file: options.outFileName || (typeof options.outSourceMap === 'string' ? options.outSourceMap.replace(/\.map$/i, '') : null),
2313723166 orig: inMap,
2313823167 root: options.sourceRoot
2313923168 });
@@ -23220,7 +23249,7 @@ exports.describe_ast = function() {
2322023249 return out + "";
2322123250};
2322223251
23223- exports. readNameCache = function(filename, key) {
23252+ var readNameCache = function(filename, key) {
2322423253 var cache = null;
2322523254 if (filename) {
2322623255 try {
@@ -23237,9 +23266,8 @@ exports.readNameCache = function(filename, key) {
2323723266 }
2323823267 return cache;
2323923268};
23240- var readNameCache = exports.readNameCache;
2324123269
23242- exports. writeNameCache = function(filename, key, cache) {
23270+ var writeNameCache = function(filename, key, cache) {
2324323271 if (filename) {
2324423272 var data;
2324523273 try {
@@ -23255,7 +23283,6 @@ exports.writeNameCache = function(filename, key, cache) {
2325523283 fs.writeFileSync(filename, JSON.stringify(data, null, 2), "utf8");
2325623284 }
2325723285};
23258- var writeNameCache = exports.writeNameCache;
2325923286
2326023287
2326123288});
@@ -28679,7 +28706,7 @@ function (args, quit, logger, build) {
2867928706 } else if (commandOption === 'v') {
2868028707 console.log('r.js: ' + version +
2868128708 ', RequireJS: ' + this.requirejsVars.require.version +
28682- ', UglifyJS: 2.7.4 ');
28709+ ', UglifyJS: 2.7.5 ');
2868328710 } else if (commandOption === 'convert') {
2868428711 loadLib();
2868528712
0 commit comments