Transpile JavaScript without running an extra node.js process.
Project description
django-compressor-js
Instead of running an extra node.js process watching for changes in your Javascript, this precompiler for django-compressor
will convert any ES6 code into ES5 automagically.
Install
pip install django-compressor-js
- Add precompiler (
text/es6
can be anything, but it has to match the script type in the template)
COMPRESS_PRECOMPILERS = (
("text/es6", "django_compressor_js.precompilers.BabelCompiler"),
)
- Add to HTML template
{% compress js %}
<script src="{% static 'js/test-es6-code.js' %}" type="text/es6"></script>
{% endcompress %}
Caveats
Most ES6 syntax seems to work pretty well, but requiring modules doesn't import correctly. Also, this approach adds some latency when compressing on the fly (i.e. COMPRESS_OFFLINE = False
).
Run tests
poetry run pytest
Credits
dukpy
and django-compressor
for doing all the hard things.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-compressor-js-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28f7d216e7c71a46d558fff4e89dd0808316844efad18fd5c158306841de3812 |
|
MD5 | 38a46c0d6cb133fd6fc00b616f09ff5d |
|
BLAKE2b-256 | 43712ad3160839644cfe8cb7c71faaeaf4ad2a4d3064bd84c2a887c8806982f1 |
Close
Hashes for django_compressor_js-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcbc1747c9e318ffe04c2da452db1ad65c1626427c782e620081a94fbea1dadc |
|
MD5 | 60a7c7db25b2239aac8bc9a5247b3bf5 |
|
BLAKE2b-256 | df89ed508743afe91fd777b1cfb8a162292d66a1933264fbe45c7161f2275646 |