Skip to content

Commit a395c07

Browse files
committed
report better errors for uglify-js
1 parent d89d2c9 commit a395c07

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/optimize/UglifyJsPlugin.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,18 @@ UglifyJsPlugin.prototype.apply = function(compiler) {
8989
compilation.warnings.push(new Error(file + " from UglifyJs\n" + warnings.join("\n")));
9090
}
9191
} catch(err) {
92-
err.file = file;
93-
compilation.errors.push(err);
92+
if(err.line) {
93+
var original = sourceMap.originalPositionFor({
94+
line: err.line,
95+
column: err.col
96+
});
97+
if(original && original.source) {
98+
compilation.errors.push(new Error(file + " from UglifyJs\n" + err.message + " [" + requestShortener.shorten(original.source) + ":" + original.line + "," + original.column + "]"));
99+
} else {
100+
compilation.errors.push(new Error(file + " from UglifyJs\n" + err.message + " [" + file + ":" + err.line + "," + err.col + "]"));
101+
}
102+
} else
103+
compilation.errors.push(new Error(file + " from UglifyJs\n" + err.message));
94104
} finally {
95105
uglify.AST_Node.warn_function = oldWarnFunction;
96106
}

0 commit comments

Comments
 (0)