Skip to content

It incorrectly minifies JS tagged template strings #432

@GresiRoost

Description

@GresiRoost

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions