drop tmp. files
This commit is contained in:
@@ -1,17 +0,0 @@
|
|||||||
var func = function TEST () {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
console.time("parse");
|
|
||||||
var ast = parse(func.toString());
|
|
||||||
console.timeEnd("parse");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ast.walk({
|
|
||||||
_visit: function(node, descend) {
|
|
||||||
console.log(node);
|
|
||||||
console.log(node.TYPE, ":", node.start.pos);
|
|
||||||
if (descend) descend.call(node);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<script src="utils.js"></script>
|
|
||||||
<script src="ast.js"></script>
|
|
||||||
<script src="parse.js"></script>
|
|
||||||
|
|
||||||
<script src="test.js"></script>
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
#! /usr/bin/env node
|
|
||||||
|
|
||||||
var sys = require("util");
|
|
||||||
var fs = require("fs");
|
|
||||||
|
|
||||||
var UglifyJS = require("../tools/node");
|
|
||||||
|
|
||||||
var files = process.argv.slice(2);
|
|
||||||
var map = UglifyJS.SourceMap();
|
|
||||||
var output = UglifyJS.OutputStream({
|
|
||||||
beautify : false,
|
|
||||||
source_map : map
|
|
||||||
});
|
|
||||||
|
|
||||||
function do_file(file) {
|
|
||||||
var code = fs.readFileSync(file, "utf8");
|
|
||||||
|
|
||||||
// parse
|
|
||||||
var ast = UglifyJS.parse(code);
|
|
||||||
|
|
||||||
// mangle
|
|
||||||
ast.figure_out_scope();
|
|
||||||
ast.mangle_names();
|
|
||||||
|
|
||||||
// compress
|
|
||||||
var compressor = UglifyJS.Compressor();
|
|
||||||
ast.squeeze(compressor);
|
|
||||||
|
|
||||||
// generate source into the output stream
|
|
||||||
// first reset the current file name in the source map.
|
|
||||||
UglifyJS.time_it("generate", function(){
|
|
||||||
map.set_source(file);
|
|
||||||
ast.print(output);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
files.forEach(do_file);
|
|
||||||
|
|
||||||
fs.writeFileSync("/tmp/source-map.json", map, "utf8");
|
|
||||||
|
|
||||||
sys.print(output);
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
#! /usr/bin/env node
|
|
||||||
|
|
||||||
var sys = require("util");
|
|
||||||
var fs = require("fs");
|
|
||||||
|
|
||||||
var UglifyJS = require("../tools/node");
|
|
||||||
|
|
||||||
var filename = process.argv[2];
|
|
||||||
var code = fs.readFileSync(filename, "utf8");
|
|
||||||
|
|
||||||
var ast = UglifyJS.parse(code);
|
|
||||||
|
|
||||||
var tt = new UglifyJS.TreeTransformer(
|
|
||||||
function before(node, descend) {
|
|
||||||
if (node instanceof UglifyJS.AST_Var) {
|
|
||||||
//return new UglifyJS.AST_EmptyStatement(node);
|
|
||||||
return UglifyJS.MAP.skip;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function after(node) {
|
|
||||||
console.log("After ", node.TYPE);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
var x = ast.transform(tt);
|
|
||||||
sys.print(x.print_to_string({ beautify: true }));
|
|
||||||
|
|
||||||
// ast.figure_out_scope();
|
|
||||||
// ast = ast.squeeze(UglifyJS.Compressor());
|
|
||||||
|
|
||||||
// ast.compute_char_frequency();
|
|
||||||
// UglifyJS.base54.sort();
|
|
||||||
|
|
||||||
// ast.figure_out_scope();
|
|
||||||
// ast.scope_warnings();
|
|
||||||
// ast.mangle_names();
|
|
||||||
|
|
||||||
// sys.error(UglifyJS.base54.get());
|
|
||||||
// sys.print(ast.print_to_string({ beautify: true }));
|
|
||||||
79
tmp/todo
79
tmp/todo
@@ -1,79 +0,0 @@
|
|||||||
✓ a = a + x ==> a+=x
|
|
||||||
|
|
||||||
*******
|
|
||||||
|
|
||||||
✓ join consecutive var statements
|
|
||||||
|
|
||||||
*******
|
|
||||||
✓
|
|
||||||
x == false ==> x == 0
|
|
||||||
x == true ==> x == 1
|
|
||||||
|
|
||||||
should warn too;
|
|
||||||
JS is so sloppy that this could be an indication of a bug.
|
|
||||||
|
|
||||||
*******
|
|
||||||
|
|
||||||
✓
|
|
||||||
|
|
||||||
x, x ==> x
|
|
||||||
x = foo, x ==> x
|
|
||||||
|
|
||||||
other similar cases?
|
|
||||||
|
|
||||||
*******
|
|
||||||
|
|
||||||
Try to concatenate all scripts somehow before starting minification;
|
|
||||||
the issue will be keeping track of the current source file for
|
|
||||||
generating source maps. perhaps store that in the AST? Have a single
|
|
||||||
AST_Toplevel for all files.
|
|
||||||
|
|
||||||
XXX? Not sure if this is worth the trouble.
|
|
||||||
|
|
||||||
*******
|
|
||||||
|
|
||||||
✓
|
|
||||||
|
|
||||||
discard spurious break statements
|
|
||||||
|
|
||||||
*******
|
|
||||||
|
|
||||||
for (...) {
|
|
||||||
if (foo) continue;
|
|
||||||
...
|
|
||||||
}
|
|
||||||
|
|
||||||
==>
|
|
||||||
|
|
||||||
for (...) {
|
|
||||||
if (!foo) { ... }
|
|
||||||
}
|
|
||||||
|
|
||||||
*******
|
|
||||||
|
|
||||||
The following seems to compress suboptimally. Should probably run more
|
|
||||||
passes somewhere.
|
|
||||||
|
|
||||||
function setOpacity(el, o) {
|
|
||||||
if (o != null) {
|
|
||||||
if (o == "" && o != 0) {
|
|
||||||
is_ie
|
|
||||||
? el.style.filter = ""
|
|
||||||
: el.style.opacity = "";
|
|
||||||
} else {
|
|
||||||
is_ie
|
|
||||||
? el.style.filter = "alpha(opacity=" + Math.round(o * 100) + ")"
|
|
||||||
: el.style.opacity = o;
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
} else {
|
|
||||||
if (!is_ie)
|
|
||||||
return parseFloat(el.style.opacity);
|
|
||||||
else
|
|
||||||
if (/alpha\(opacity=([0-9.])+\)/.test(el.style.opacity))
|
|
||||||
return parseFloat(RegExp.$1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*******
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user