Print proper error from uglify

Reviewed By: jeanlauliac

Differential Revision: D5264809

fbshipit-source-id: 2a2c7c9af74e8c87acf68e2e9205c85b7aea2fb9
This commit is contained in:
Christoph Pojer 2017-06-16 10:18:11 -07:00 committed by Facebook Github Bot
parent 2a085f0c1b
commit 54c4aed3b4
1 changed files with 22 additions and 14 deletions

View File

@ -183,19 +183,27 @@ exports.transformAndExtractDependencies = (
);
};
exports.minify = (
filename: string,
code: string,
sourceMap: MappingsMap,
callback: Callback<{code: string, map: MappingsMap}>,
) => {
var result;
try {
result = minify.withSourceMap(code, sourceMap, filename);
} catch (error) {
callback(error);
}
callback(null, result);
};
exports.minify = asyncify(
(filename: string, code: string, sourceMap: MappingsMap) => {
var result;
try {
result = minify.withSourceMap(code, sourceMap, filename);
} catch (error) {
if (error.constructor.name === 'JS_Parse_Error') {
throw new Error(
error.message +
' in file "' +
filename +
'" at line ' +
error.line +
':' +
error.col,
);
}
throw error;
}
return result;
},
);
exports.transformCode = transformCode; // for easier testing