Commit b3c8eb23 authored by Robert Knight's avatar Robert Knight

Fix warning about missing inline source map

If minifying code that does not contain an inline sourcemap, don't set
the `sourceMap { content: "inline" }` Terser option to read that
sourcemap. This affects a subset of all the vendor modules that are
included in the Hypothesis client build.
parent 652c8924
......@@ -29,14 +29,20 @@ function minifyStream() {
async flush(callback) {
const code = Buffer.concat(this.chunks).toString();
const minifyResult = await terser.minify(code, {
// See https://github.com/terser/terser#minify-options-structure
sourceMap: {
const options = {};
// If the code we're minifying has a sourcemap then generate one for the
// minified output, otherwise skip it.
if (code.includes('sourceMappingURL=data:')) {
options.sourceMap = {
content: 'inline',
url: 'inline',
},
});
};
}
const minifyResult = await terser.minify(code, options);
this.push(minifyResult.code);
callback();
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment