Permalink
Browse files

Updated dependencies + Refactor

+ Updated all dependencies (core & middleware) to their latest versions
+ Refactored to make the system compatible with new libraries
+ Lock core dependencies to ensure stability
  • Loading branch information...
mendezcode committed Dec 9, 2012
1 parent a1b02b4 commit 23bbf548772fcbb433661b29321c81081c203691
Showing with 51 additions and 55 deletions.
  1. +18 −18 dependencies.json
  2. +1 −4 engines/kernel.js
  3. +14 −15 middleware/asset_compiler/asset-minifier.js
  4. +12 −12 package.json
  5. +6 −6 test/middleware/asset_compiler.js
View
@@ -10,37 +10,37 @@
},
"redis": {
"redis" : "= 0.7.2",
- "hiredis" : ">= 0.1.14"
+ "hiredis" : "= 0.1.14"
},
"middleware": {
"asset_compiler": {
- "coffee-script" : "= 1.3.3",
- "less" : "= 1.3.0",
- "stylus" : "= 0.28.2",
- "nib" : "= 0.7.0",
- "clean-css" : "= 0.6.0",
- "uglify-js" : "= 1.3.3"
+ "coffee-script" : "= 1.4.0",
+ "less" : "= 1.3.1",
+ "stylus" : "= 0.31.0",
+ "nib" : "= 0.9.0",
+ "clean-css" : "= 0.8.3",
+ "uglify-js" : "= 2.2.2"
},
"aws": {
"aws2js" : "= 0.7.3"
},
"mq": {
- "amqp" : ">= 0.1.3"
+ "amqp" : ">= 0.1.4"
},
"bcrypt": {
- "bcrypt" : ">= 0.7.1"
+ "bcrypt" : ">= 0.7.3"
},
"body_parser": {
"formidable" : ">= 1.0.11"
},
"mailer": {
- "nodemailer" : ">= 0.3.27"
+ "nodemailer" : ">= 0.3.35"
},
"magick": {
- "node-imagemagick" : ">= 0.1.7"
+ "node-imagemagick" : ">= 0.1.8"
},
"markdown": {
- "marked" : ">= 0.2.5"
+ "marked" : ">= 0.2.6"
},
"socket_io": {
"socket.io" : ">= 0.9.9"
@@ -50,17 +50,17 @@
"coffeekup" : ">= 0.3.1",
"dot" : ">= 0.2.6",
"eco" : ">= 1.1.0-rc-3",
- "hamljs" : ">= 0.6.0",
- "haml-coffee" : ">= 1.4.1",
- "handlebars" : ">= 1.0.6-2",
+ "hamljs" : ">= 0.6.1",
+ "haml-coffee" : ">= 1.8.2",
+ "handlebars" : ">= 1.0.7",
"hogan.js" : ">= 2.0.0",
- "jade" : ">= 0.27.2",
+ "jade" : ">= 0.27.7",
"jazz" : ">= 0.0.18",
"jqtpl" : ">= 1.1.0",
"jshtml" : ">= 0.2.3",
- "kernel" : "= 0.0.2",
+ "kernel" : ">= 0.1.4",
"liquor" : ">= 0.0.4",
- "swig" : ">= 0.12.0",
+ "swig" : ">= 0.13.3",
"whiskers" : ">= 0.2.3"
}
}
View
@@ -52,11 +52,8 @@ Kernel.prototype.render = function(data) {
}
Kernel.prototype.compile = function(source, vars, relPath) {
- /*jshint evil:true */
try {
- return new Function("var helpers = this;\nreturn "
- + generator(parser(tokenizer(source), source, this.app.fullPath(relPath))))
- .call(helpers);
+ return kernel.compile(source, relPath)
} catch(e) {
return e;
}
@@ -25,10 +25,6 @@ var compiler = new Multi({
}
});
-// Uglifyjs internals
-var jsp = uglifyjs.parser;
-var pro = uglifyjs.uglify;
-
// Recursive minification
function minification() {
var sources, target = minifyTargets.shift();
@@ -48,11 +44,7 @@ function minification() {
fs.writeFileSync(target, source, 'utf8');
app.debug("Asset Compiler: Minified CSS: " + app.relPath(target));
} else if (ext == 'js') {
- var ast = jsp.parse(compiled.join('\n'), config.uglifyOpts.strictSemicolons); // Initial AST
- if (config.uglifyOpts.mangle) ast = pro.ast_mangle(ast); // Mangled names
- if (config.uglifyOpts.liftVariables) ast = pro.ast_lift_variables(ast) // Declare vars at top of scope
- if (config.uglifyOpts.squeeze) ast = pro.ast_squeeze(ast); // Compression optimizations
- var outSrc = pro.gen_code(ast); // Compressed code
+ var outSrc = minifyJS(compiled.join('\n'));
fs.writeFileSync(target, outSrc, 'utf8');
app.debug("Asset Compiler: Minified JavaScript: " + app.relPath(target));
} else {
@@ -64,12 +56,19 @@ function minification() {
}
}
-/*
-mangle: true,
-squeeze: true,
-liftVariables: false,
-strictSemicolons: false
-*/
+function minifyJS(code) {
+ var ast, compressor, stream;
+ ast = uglifyjs.parse(code, {});
+ compressor = uglifyjs.Compressor();
+ ast.figure_out_scope();
+ ast = ast.transform(compressor);
+ ast.figure_out_scope();
+ ast.compute_char_frequency();
+ ast.mangle_names();
+ stream = uglifyjs.OutputStream();
+ ast.print(stream);
+ return stream.toString();
+}
function getExt(file) {
return file.slice(file.lastIndexOf('.')+1).trim().toLowerCase();
View
@@ -14,20 +14,20 @@
"npm": "1.1.x"
},
"dependencies" : {
- "underscore" : ">= 1.3.3",
- "underscore.string" : ">= 2.2.0rc",
- "node-uuid" : ">= 1.3.3",
- "sanitizer" : ">= 0.0.15",
- "bouncy" : ">= 1.3.1",
- "multi" : ">= 0.1.2",
- "file" : ">= 0.2.1",
- "mime" : ">= 1.2.7",
- "qs" : ">= 0.5.0",
- "ejs" : ">= 0.8.0"
+ "underscore" : "= 1.4.3",
+ "underscore.string" : "= 2.3.1",
+ "node-uuid" : "= 1.4.0",
+ "sanitizer" : "= 0.0.15",
+ "bouncy" : "= 1.3.1",
+ "multi" : "= 0.1.2",
+ "file" : "= 0.2.1",
+ "mime" : "= 1.2.7",
+ "qs" : "= 0.5.2",
+ "ejs" : "= 0.8.3"
},
"devDependencies" : {
- "jshint" : ">= 0.7.3",
- "vows" : ">= 0.6.3",
+ "jshint" : ">= 0.9.1",
+ "vows" : ">= 0.7.0",
"node-inspector" : ">= 0.2.0beta3"
}
}
@@ -135,12 +135,12 @@ color:#222}#toc-sidebar ul li.section{margin-top:.5em}#toc-sidebar ul li.section
li.sub{margin-left:0}#yelow #short{color:#fea}#yelow #long{color:#fea}#yelow #rgba{color:rgba(255,238,170,.1)}#yelow \
#argb{color:#1affeeaa}';
- var expected2 = '(function(){var e,t,n,r,i,s,o,u,a=Array.prototype.slice;i=42,s=!0,s&&(i=-42),u=function(e){return e*e\
-},t=[1,2,3,4,5],n={root:Math.sqrt,square:u,cube:function(e){return e*u(e)}},o=function(){var e,t;return t=arguments[0],e=2<\
-=arguments.length?a.call(arguments,1):[],print(t,e)},typeof elvis!="undefined"&&elvis!==null&&alert("I knew it!"),e=function\
-(){var e,i,s;s=[];for(e=0,i=t.length;e<i;e++)r=t[e],s.push(n.cube(r));return s}()}).call(this),function(){var e,t,n,r;r=["do\
-","re","mi","fa","so"],n={Jagger:"Rock",Elvis:"Roll"},e=[1,0,1,0,0,1,1,1,0],t={brother:{name:"Max",age:11},sister:{name:"Ida\
-",age:9}}}.call(this)';
+ var expected2 = '(function(){var e,r,n,t,a,u,i,l,o=Array.prototype.slice;a=42,u=!0,u&&(a=-42),l=function(e){return e*e}\
+,r=[1,2,3,4,5],n={root:Math.sqrt,square:l,cube:function(e){return e*l(e)}},i=function(){var e,r;return r=arguments[0],\
+e=arguments.length>=2?o.call(arguments,1):[],print(r,e)},"undefined"!=typeof elvis&&null!==elvis&&alert("I knew it!"),\
+e=function(){var e,a,u;for(u=[],e=0,a=r.length;a>e;e++)t=r[e],u.push(n.cube(t));return u}()}).call(this),function(){var e,r,\
+n,t;t=["do","re","mi","fa","so"],n={Jagger:"Rock",Elvis:"Roll"},e=[1,0,1,0,0,1,1,1,0],r={brother:{name:"Max",age:11},\
+sister:{name:"Ida",age:9}}}.call(this);';
assert.equal(r1, expected1);
assert.equal(r2, expected2);

0 comments on commit 23bbf54

Please sign in to comment.