bin/roll.js in snowball-0.1.3 vs bin/roll.js in snowball-0.1.4
- old
+ new
@@ -51,11 +51,11 @@
}
bundle = browserify();
// Todo: make jade-support optional (consider snowball plugins?)
-bundle.register('.jade', function () {
+bundle.register('.jade', (function () {
var compileDebug = !!(argv.env && argv.env.hasOwnProperty('NODE_ENV') && argv.env.NODE_ENV == 'development');
return function (b, filename) {
var body = fs.readFileSync(filename);
var compiled;
try {
@@ -64,22 +64,22 @@
client: true,
compileDebug: compileDebug
}).toString();
}
catch (e) {
- // There's a syntax error in the template. Wrap it into a function that will throw an error when templates is used
- compiled = "function() {throw new Error(unescape('"+escape(e.toString()+"\nIn "+filename)+"'))}"
+ // There's a syntax error in the template. Wrap it into a function that will immediately throw an error
+ return '\nthrow new '+ e.name +'('+JSON.stringify(e.message)+');';
}
// Wrap the compiled template function in a function that merges in previously registered globals (i.e. helpers, etc)
return ''+
'var jade = require("jade-runtime").runtime;' +
'module.exports = function(locals, attrs, escape, rethrow, merge) {' +
' var locals = require("jade-runtime").globals.merge(locals);' +
' return ('+compiled+")(locals, attrs, escape, rethrow, merge);" +
'}';
}
-});
+})());
if (argv.prelude === false) {
bundle.files = [];
bundle.prepends = [];
}
@@ -107,15 +107,11 @@
if (argv.ignore) {
bundle.ignore(argv.ignore);
}
-bundle.on("loadError", function(e) {
- bundle.prepend('\nthrow new Error('+JSON.stringify(e.message)+');');
-});
-
bundle.on("syntaxError", function(e) {
- bundle.prepend('throw new Error('+JSON.stringify(e.message)+');');
+ bundle.prepend('throw new SyntaxError('+JSON.stringify(e.toString())+');');
});
(argv._.concat(argv.entry || [])).forEach(function (entry) {
try {
bundle.addEntry(entry);