Rich-Harris / butternut

The fast, future-friendly minifier
https://butternut.now.sh
MIT License
1.17k stars 17 forks source link

Fold constants in template literals #62

Closed Rich-Harris closed 7 years ago

Rich-Harris commented 7 years ago

This gets folded...

// input
console.log( `running in ${true ? 'development' : 'production'} mode` );

// output
console.log("running in development mode");

...but this doesn't:

// input
console.log( `running in ${true ? 'development' : 'production'} mode. The time is ${Date.now()}` );

// output
console.log(`running in ${'development'} mode. The time is ${Date.now()}`)

// ideal
console.log(`running in development mode. The time is ${Date.now()}`)