ndparker / rjsmin

Fast javascript minifier for Python
http://opensource.perlig.de/rjsmin/
Apache License 2.0
60 stars 15 forks source link

Template literals not minified properly #16

Closed gmgdeploy closed 5 years ago

gmgdeploy commented 5 years ago

Hello,

When I have:

url = `${location.protocol}//${location.host}${url}`;

It gets minified to:

url=`${location.protocol}

It seems that everything that follows '//' is interpreted as a comment and removed.

ndparker commented 5 years ago

Hi, have you updated to the latest version? It introduced basic support for template literals.

krisb78 commented 5 years ago

This happens on 1.1.0 (I raised this from a wrong account, sorry)

ndparker commented 5 years ago

I cannot reproduce with your test case. Both of these give the correct result:

python -mrjsmin -p <<<'url = `${location.protocol}//${location.host}${url}`;'
python -mrjsmin <<<'url = `${location.protocol}//${location.host}${url}`;'

So what could be is that it falls out of sync before that code for some reason. Questions right now would be: 1) Do these examples work for you? 2) If yes, can you provide me a better one? :-) 3) If no, can you double-check that you're using the current version (starting from an empty venv perhaps)

Thanks.

krisb78 commented 5 years ago

I think I barked at the wrong tree. I'm using rjsmin via django-compressor, and it seems it's the latter that's responsible for doing this. sorry!

1oglop1 commented 4 years ago

@krisb78 for what it's worth I noticed the same problem in webassets which maintains it's own copy of rjsmin which is a few versions behind this.