Open 1oglop1 opened 4 years ago
Right now you're seeing a hack in rjsmin. Since it's regex based it cannot easily handle nested template strings (or JS code inside template strings for that matter), so it treats them as "regular" strings. That way, they don't break per se, but as a tradeoff are not minified (inside) either.
Until I've found a better a solution, that's how it is, sorry.
Thanks for the quick response, this is what I thought.
Do you think that this could help to build better regexes? https://github.com/VerbalExpressions/PythonVerbalExpressions
(PS I could not make rjsmin running by python -m rjsmin
it just hung on python 3.6.9`)
No. The problem is that it's recursive, which cannot be mapped to regular expressions at all. So I need a way out of this, kind of similar to what I do in rcssmin. The main idea would be to split up the code-to-be-minified and process it in pieces. Not sure if it will work out. However I still need some time to test that theory :-)
python -m rjsmin
waits for stdin. may thatswhy? The usage would be, e.g.
$ python -mrjsmin <test.js
I guess this could help with parsing https://github.com/Kronuz/esprima-python, I do not have much experience with it but it looks something like which can do the job.
Ad. waits for stdin,... I see it now, I interpreted the readme differently python -mrjsmin <script >minified
and my dyslectic brain took the <script>
as a placeholder instead of interpreting it as in/out redirection :), also the reason I'm so dependent on syntax highlighter.
Hi, I found similar problem has been discussed in #8 and #16.
I'm fairly new to JS so please enlighten me if what am I reporting is a duplicate and why.
I have this
test.js
which get's minified into
As you can see some parts were minified but the whitespace around ternary operator is preserved
expected output is: