[Pkg-javascript-commits] [leaflet-markercluster] 334/479: Fix #155, work with uglify-js version 2
Jonas Smedegaard
dr at jones.dk
Thu Oct 16 16:00:48 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository leaflet-markercluster.
commit ce0a1f6fa645edd0dcda6aa8f5e790f344c43c3b
Author: Pieter van der Eems <p.van.der.eems at interactiveblueprints.nl>
Date: Fri Apr 12 16:14:30 2013 +0200
Fix #155, work with uglify-js version 2
---
build/build.js | 65 ++++++++++++++++++++++++++++++++++++----------------------
1 file changed, 41 insertions(+), 24 deletions(-)
diff --git a/build/build.js b/build/build.js
index 355e740..40cc948 100644
--- a/build/build.js
+++ b/build/build.js
@@ -4,55 +4,72 @@ var fs = require('fs'),
exports.getFiles = function (compsBase32) {
var memo = {},
- comps;
+ comps,
+ i,
+ files = [],
+ src;
if (compsBase32) {
comps = parseInt(compsBase32, 32).toString(2).split('');
- console.log('Managing dependencies...')
+ console.log('Managing dependencies...');
}
function addFiles(srcs) {
- for (var j = 0, len = srcs.length; j < len; j++) {
+ var j,
+ len;
+ for (j = 0, len = srcs.length; j < len; j += 1) {
memo[srcs[j]] = true;
}
}
- for (var i in deps) {
- if (comps) {
- if (parseInt(comps.pop(), 2) === 1) {
- console.log('\t* ' + i);
- addFiles(deps[i].src);
+ for (i in deps) {
+ if (deps.hasOwnProperty(i)) {
+ if (comps) {
+ if (parseInt(comps.pop(), 2) === 1) {
+ console.log('\t* ' + i);
+ addFiles(deps[i].src);
+ } else {
+ console.log('\t ' + i);
+ }
} else {
- console.log('\t ' + i);
+ addFiles(deps[i].src);
}
- } else {
- addFiles(deps[i].src);
}
}
- var files = [];
-
- for (var src in memo) {
- files.push('src/' + src);
+ for (src in memo) {
+ if (memo.hasOwnProperty(src)) {
+ files.push('src/' + src);
+ }
}
return files;
};
exports.uglify = function (code) {
- var pro = uglifyjs.uglify;
+ var ast,
+ compressor;
+ ast = uglifyjs.parse(code);
+
+ // compressor needs figure_out_scope too
+ ast.figure_out_scope();
+ compressor = uglifyjs.Compressor();
+ ast = ast.transform(compressor);
- var ast = uglifyjs.parser.parse(code);
- ast = pro.ast_mangle(ast, {mangle: true});
- ast = pro.ast_squeeze(ast);
- ast = pro.ast_squeeze_more(ast);
+ // need to figure out scope again so mangler works optimally
+ ast.figure_out_scope();
+ ast.compute_char_frequency();
+ ast.mangle_names();
- return pro.gen_code(ast) + ';';
+ // get Ugly code back :)
+ return ast.print_to_string();
};
exports.combineFiles = function (files) {
- var content = '(function (window, undefined) {\n\n';
- for (var i = 0, len = files.length; i < len; i++) {
+ var content = '(function (window, undefined) {\n\n',
+ i,
+ len;
+ for (i = 0, len = files.length; i < len; i += 1) {
content += fs.readFileSync(files[i], 'utf8') + '\n\n';
}
return content + '\n\n}(this));';
@@ -76,4 +93,4 @@ exports.getSizeDelta = function (newContent, oldContent) {
}
var delta = newContent.length - oldContent.length;
return (delta >= 0 ? '+' : '') + delta;
-};
\ No newline at end of file
+};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/leaflet-markercluster.git
More information about the Pkg-javascript-commits
mailing list