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

View File

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