minify icon indicating copy to clipboard operation
minify copied to clipboard

It incorrectly minifies JS tagged template strings

Open GresiRoost opened this issue 4 months ago • 0 comments

In some occasions the minifier will incorrectly attempt to minify inside of tagged template strings:

Minimal example:

let test = html`
    <div>
       ${true ? html`
            <div>
                <span style="woo" ...${{foo:"bar"}}>${children}</span>
            </div>
        ` : null}
    </div>
`;

The incorrect output:

let test=html`
    <div>
       ${true ? html`<div><span style="woo"...${{foo:"bar"}}>${children}</span></div>` : null}
    </div>
`

Tehcnically it should not touch tagged template strings at all (and it doesn't in the outer one), but once it gets to the inner one it begins to remove space around tags.

Preact keeps working with this as the whitespace is not important between tags, but the breaking error here is that it removes the space before the '...'. This breaks the code.

Note: This is not HTML, it is HTML data inside of a string that the minifier should not touch at all.

GresiRoost avatar Oct 08 '24 12:10 GresiRoost