You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use terser https://github.com/terser/terser with django-compressor. It's working quite fine except that I have an issue I do not understand.
Once compressed, some of my output files are missing some data compared to the originals (some functions disappear especially). But when I run terser from the command line (outside of django) with the same argument, everything is fine. Here is what I use from the command line to get the right results:
and here is the custom TerserJSFilter I have created (inspired from ClosureCompilerFilter):
terser.py in appName/compressor/filters folder
from compressor.conf import settings
from compressor.filters import CompilerFilter
class TerserJSFilter(CompilerFilter):
command = "{binary} {args}"
options = (
("binary", settings.COMPRESS_TERSER_BINARY),
("args", settings.COMPRESS_TERSER_JS_ARGUMENTS),
)
Am I implementing terser correctly or missing something?
Is there a way to get more detailed logs from django-compressor in order to have a better understanding of what's going on?
Does someone have an idea about why I have some data not taken into account/deleted in my output compressed files?
Thank you in advance
The text was updated successfully, but these errors were encountered:
ok, my bad. Looks like my issue comes from terser, not from django-compressor. Looks like using --toplevel argument has some nice effects I do not understand yet.
I prefer to not delete my post since I have not found any information about how to implement a custom filter like terser with django-compressor. So it might useful to others.
If you have any hint about terser behavior with --toplevel and why some functions and parts of code are deleted please let me know.
EDIT: Finally found why some code was remove. "-c" argument, which stands for "--compress" is also performing dead code removal. Since I am using some helper functions for other scripts, they were considered as dead code because not used in the scope of the analyzed file. nothing to do with --toplevel directly. To solve this, I passed the following option to compress: 'dead_code=false, unused=false'. My final arguments setting for TERSER in settings.py is now:
I am trying to use terser https://github.com/terser/terser with django-compressor. It's working quite fine except that I have an issue I do not understand.
Once compressed, some of my output files are missing some data compared to the originals (some functions disappear especially). But when I run terser from the command line (outside of django) with the same argument, everything is fine. Here is what I use from the command line to get the right results:
terser <input_file> -c -m --keep-fnames --toplevel -o <output_file>
and here the equivalent arguments in settings.py :
COMPRESS_TERSER_JS_ARGUMENTS = "-c -m --keep-fnames --toplevel"
Here are the settings I have:
settings.py
and here is the custom TerserJSFilter I have created (inspired from ClosureCompilerFilter):
terser.py in appName/compressor/filters folder
Am I implementing terser correctly or missing something?
Is there a way to get more detailed logs from django-compressor in order to have a better understanding of what's going on?
Does someone have an idea about why I have some data not taken into account/deleted in my output compressed files?
Thank you in advance
The text was updated successfully, but these errors were encountered: