Siorki / RegPack

Self-contained packer for size-constrained JS code
Other
301 stars 14 forks source link

Do not remove newlines or trailing blanks in template literals #96

Closed Siorki closed 2 years ago

Siorki commented 5 years ago

RegPack.runPacker() starts with :

// clear leading/trailing blanks and one-liner comments
var input = input.replace(/([\r\n]|^)\s*\/\/.*|[\r\n]+\s*/g,'');

This code was ok until ES5 but has unexpected side effects with template literals in ES6. Namely, removing intentional blanks and newlines.

=> Do not change the contents of template literals. Maybe push this piece of code to the preprocessor.