Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for js source maps #438

Open
polmuz opened this issue Sep 4, 2013 · 20 comments
Open

Support for js source maps #438

polmuz opened this issue Sep 4, 2013 · 20 comments
Labels

Comments

@polmuz
Copy link

polmuz commented Sep 4, 2013

Source maps are a very nice tool for debugging something on compressed code using Chrome Dev Tools. There are lots of tools that generate them including Google closure that is already supported by django-compressor.

Here's some info: https://github.com/ryanseddon/source-map/wiki/Source-maps%3A-languages,-tools-and-other-info

@polmuz
Copy link
Author

polmuz commented Sep 4, 2013

I'm willing to implement it but I'd like to know if there's any interest about this feature.

So far I've been reading the code to get an idea of what is needed to accomplish this.

First, on the template tags side, there are at least two options to turn on source maps, a parameter for the compressor or a different compressor: {% compress js sourcemap %} or {% compress js-sourcemaps %}

Then, if source maps option is on, the compressor should check that all the hunks are files because you can't generate source maps for inline (I think, not completely sure).

Finally, maybe the trickiest part, a compressor backend that can handle a list of files and output the compressed js and the source map file is needed.

I'd love to get some feedback on this to know if I'm on track or I got everything wrong.

@Nagyman
Copy link

Nagyman commented Sep 12, 2013

This may be possible with the existing toolchain. I've managed to get basic sourceMapURL support for CSS via SASS.

e.g. https://gist.github.com/Nagyman/6542739

This is very preliminary; some known limitations are mentioned in the comments.

@davisein
Copy link

davisein commented Feb 4, 2014

I am interested. It would easy fast debugging staging code.
Any advance on this feature?

@sicarrots
Copy link

Yes, i'm currently working on this feature.

@agriffis
Copy link
Contributor

agriffis commented Feb 6, 2014

@sicarrots I'm using source maps when settings.DEBUG since compressor just passes through the original tags, but it seems pretty tricky to make them work after concatenation and relocation. How are you approaching it?

@Kos
Copy link

Kos commented Feb 6, 2014

I'm having some success experimenting with Compressor and uglify.js. For now I've subclassed the JsCompressor and overridden output to work around the whole filter/concat/filter chain and only use Uglify for all activities (concat, compress, generate source maps).

@fetzig
Copy link

fetzig commented Feb 15, 2014

source maps are used by sentry too https://www.getsentry.com/docs/sourcemaps/

@Kos
Copy link

Kos commented Feb 15, 2014

@fetzig Exactly my rationale behind doing that

@jpic
Copy link

jpic commented Feb 27, 2014

@Kos Would you kindly paste some code for inspiration purposes ? Thanks B)

@Kos
Copy link

Kos commented Feb 28, 2014

This is what I ended up using: https://gist.github.com/Kos/9270494 (I have offline compression on production and no compression in development)

Next step would be to allow using {% compress js %} for the normal JsCompressor (because the filter/concat/filter chain sometimes does get helpful) and set up something like {% compress uglify %} to use my custom class, but I haven't figured out a way to do that by configuration.

edit: 🍻 :-)

@iknite
Copy link
Contributor

iknite commented Feb 28, 2014

🍻 @Kos!

@spinus
Copy link

spinus commented Oct 29, 2014

+1 for that feature!

@spinus
Copy link

spinus commented Nov 1, 2014

@vladlep
Copy link

vladlep commented Jul 7, 2015

+1 I would like this feature also. It is very handy to be able to debug JS compressed files in production. Sentry errors do not make much sense if not.

@woile
Copy link

woile commented Jul 7, 2015

+1 for the feature, absolutely required for Sentry errors :)

@wtayyeb
Copy link

wtayyeb commented Oct 21, 2015

+1 for js and css source maps

@ace-han
Copy link

ace-han commented May 23, 2016

I would like to see js/ES6/coffee(even TypeScript) and css/sass/less source map
🍻

@travijuu
Copy link

Does Compress still not support source maps feature?

@diox
Copy link
Member

diox commented Mar 28, 2017

No, it still does not support that feature. You're welcome to submit a PR implementing this.

@imposeren
Copy link

It's still possible to implement some "hackish" solution, for example:
https://bitbucket.org/imposeren/tabletop-planning/src/7d551806cfee2c5493b7273e40c5448aec480544/tabletop_tools/compressor_filters.py?at=master

Better solution is required to make PR...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests