ayudapy icon indicating copy to clipboard operation
ayudapy copied to clipboard

try terser as JS minifier

Open melizeche opened this issue 4 years ago • 5 comments

just a draft, @jorgeramirez @juanhuttemann can you guys tests if this approach is valid for #261 ? reqs: npm install -g terser

ref: https://django-pipeline.readthedocs.io/en/latest/compressors.html#example

melizeche avatar Apr 20 '20 02:04 melizeche

@melizeche thanks!

I haven't tested it yet. But you could try using shutil package to discover the path to terser in a cross-platform way. For example

import shutil
print(shutil.which("yuglify"))
> '/Users/jorge/.nvm/versions/node/v8.9.1/bin/yuglify'

I'll check your changes soon. I also wonder if this tool does the "translating" part (ES6+ => ES5).

jorgeramirez avatar Apr 20 '20 02:04 jorgeramirez

it's a minifier but we don't need translate to ES5, ES6 at least const is supported since android 2.2 https://caniuse.com/#search=const we just need not to go full ES7 features and we will be fine I think... and fuck IE edit: I misread the comment

melizeche avatar Apr 20 '20 02:04 melizeche

@juanhuttemann in theory it should work fine with env as https://github.com/melizeche/ayudapy/pull/268/files#diff-5e96265fa524caa1877f88f3c1958635R4 but didt't work on my case

melizeche avatar Apr 20 '20 17:04 melizeche

@juanhuttemann in theory it should work fine with env as https://github.com/melizeche/ayudapy/pull/268/files#diff-5e96265fa524caa1877f88f3c1958635R4 but didt't work on my case

fix to work on any platform

import shutil
...
TERSER_BINARY = shutil.which("terser")

juanhuttemann avatar Apr 22 '20 19:04 juanhuttemann

@melizeche it works like a charm, though I used @juanhuttemann fix. I guess if you update the PR with his suggestion is good to go 👌

jorgeramirez avatar Apr 25 '20 01:04 jorgeramirez