Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
get parseTree() {
if (!this._parseTree) {
var text = this.text;
// If the source ends with one or more comment, add an empty statement at the end so there's a token
// for the UglifyJS parser to attach them to (workaround for https://github.com/mishoo/UglifyJS2/issues/180)
if (/(?:\/\/[^\r\n]*|\*\/)[\r\s\n]*$/.test(text)) {
text += '\n;';
}
try {
this._parseTree = uglifyJs.parse(text);
} catch (e) {
var err = new errors.ParseError({
message: 'Parse error in ' + this.urlOrDescription + '\n' + e.message + ' (line ' + e.line + ', column ' + (e.col + 1) + ')',
line: e.line,
column: e.col + 1,
asset: this
});
if (this.assetGraph) {
this.assetGraph.emit('warn', err);
} else {
throw err;
}
this._parseTree = uglifyJs.parse('');
}
}
return this._parseTree;
}
try {
this._parseTree = uglifyJs.parse(text);
} catch (e) {
var err = new errors.ParseError({
message: 'Parse error in ' + this.urlOrDescription + '\n' + e.message + ' (line ' + e.line + ', column ' + (e.col + 1) + ')',
line: e.line,
column: e.col + 1,
asset: this
});
if (this.assetGraph) {
this.assetGraph.emit('warn', err);
} else {
throw err;
}
this._parseTree = uglifyJs.parse('');
}
}
return this._parseTree;
},