Open
Description
This was also an issue with JShrink: tedious/JShrink#87 and is actually how I came across your issue related to that here: tedious/JShrink#105
But I'm still seeing this issue with js-minify.
For example:
function hello () {
console.log('Hello World')
}
console.log('yay')
Should become:
function hello(){console.log('Hello World')}console.log('yay')
But currently it becomes:
function hello(){console.log('Hello World')}
console.log('yay')
Activity
garfix commentedon Nov 10, 2021
Hi @kodie,
The reason why the library doesn't remove this whitespace can best be explained with a simple example:
if this becomes
the result of evaluation is
Uncaught SyntaxError: Unexpected identifier
I think this issue can only be resolved by full parsing the javascript file but this takes a lot of time.
kodie commentedon Nov 11, 2021
@garfix In that case, couldn't we have it append a semicolon to the end of the function? So it becomes:
garfix commentedon Nov 11, 2021
I elaborated on the semicolon versus newline decision in #1.