GuillaumeGomez / minifier-rs

Minifier tool/lib for JS/CSS/JSON files
MIT License
86 stars 16 forks source link

Incorrect behavior with spaces in template strings (backtick) #61

Closed balthild closed 3 years ago

balthild commented 3 years ago
fn test_minifier() {
    let js = r###"
        const a = 123;
        const b = "123";
        const c = `the number is ${a}  <-- note the spaces here`;
        const d = `      ${a}         ${b}      `;
    "###;
    println!("{:?}", minifier::js::minify(js));
}

The above code outputs

"const a=123;const b=\"123\";const c=`the number is ${a}<--note the spaces here`;const d=` ${a}${b}`"

The correct output is

"const a=123;const b=\"123\";const c=`the number is ${a}  <-- note the spaces here`;const d=`      ${a}         ${b}      `"
GuillaumeGomez commented 3 years ago

Good catch! It means that the string parsing is invalid then...

GuillaumeGomez commented 3 years ago

I'll make a release soon. I'm doing a big cleanup before that.

GuillaumeGomez commented 3 years ago

There is a new release with the fix.

balthild commented 3 years ago

Thanks!