Skip to content

Commit

Permalink
Spacebars-compiler npm ReferenceError error has been fixed in the _be…
Browse files Browse the repository at this point in the history
…autify function. meteor#244
  • Loading branch information
Yasar icli committed Mar 20, 2017
1 parent cc8014e commit 4babdca
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions packages/spacebars-compiler/compiler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
var UglifyJSMinify = Npm.require('uglify-js').minify;

SpacebarsCompiler.parse = function (input) {

var tree = HTMLTools.parseFragment(
Expand Down Expand Up @@ -96,20 +94,26 @@ SpacebarsCompiler.codeGen = function (parseTree, options) {
};

SpacebarsCompiler._beautify = function (code) {
var result = UglifyJSMinify(code, {
fromString: true,
mangle: false,
compress: false,
output: {
beautify: true,
indent_level: 2,
width: 80
}
});

var output = result.code;
// Uglify interprets our expression as a statement and may add a semicolon.
// Strip trailing semicolon.
output = output.replace(/;$/, '');
return output;
try {
var UglifyJSMinify = Npm.require('uglify-js').minify;
var result = UglifyJSMinify(code, {
fromString: true,
mangle: false,
compress: false,
output: {
beautify: true,
indent_level: 2,
width: 80
}
});

var output = result.code;
// Uglify interprets our expression as a statement and may add a semicolon.
// Strip trailing semicolon.
output = output.replace(/;$/, '');
return output;

} catch (e) {
return code;
}
};

0 comments on commit 4babdca

Please sign in to comment.