function rollDieInline()
{
return `The die shows ${Math.ceil(Math.random() * 6)}.`;
}
After compiling with outputFormat: minify, the JS portion of the output was not minified. No error messages or exceptions were observed.
Running command-line uglifyjs manually against this file threw an error `unexpected character `` on that function. Apparently UglifyJS doesn't like string interpolation in return statements for some reason?
So there's that, and there's also the broader issue that html-minifier appears to be swallowing errors/exceptions from UglifyJS. I was able to get some log messages out by setting the log: (function) property in the html-minifier options (when calling it in Compiler.ApplyTemplate) and while UglifyJS does hand that callback an object containing a line/column number and error message, the position doesn't match up with anything useful, because it's an offset into a dynamic buffer that's already been through one or two other minification passes (css and html) and doesn't map to any actual source file any more.
The right solution may be to call UglifyJS separately rather than letting html-minifier do all the work for us, and then we can handle its errors directly, and at least return relevant surrounding context from the working minification buffer when an error is thrown.
In user script, I had a function like this:
After compiling with
outputFormat: minify
, the JS portion of the output was not minified. No error messages or exceptions were observed.Running command-line
uglifyjs
manually against this file threw an error `unexpected character `` on that function. Apparently UglifyJS doesn't like string interpolation in return statements for some reason?So there's that, and there's also the broader issue that html-minifier appears to be swallowing errors/exceptions from UglifyJS. I was able to get some log messages out by setting the
log: (function)
property in the html-minifier options (when calling it inCompiler.ApplyTemplate
) and while UglifyJS does hand that callback an object containing a line/column number and error message, the position doesn't match up with anything useful, because it's an offset into a dynamic buffer that's already been through one or two other minification passes (css and html) and doesn't map to any actual source file any more.The right solution may be to call UglifyJS separately rather than letting html-minifier do all the work for us, and then we can handle its errors directly, and at least return relevant surrounding context from the working minification buffer when an error is thrown.