Generate source maps for bundled files #397

jrburke opened this Issue Mar 6, 2013 · 9 comments


None yet
6 participants

jrburke commented Mar 6, 2013

For concatenated/bundled build layers, support source map generation so that a source map-enabled browser could allow debugging of the combined file as separate files for each module.

This should work without minifying, so if optimize: 'none' is in play. Then, also connect that source map bundle with the one uglifyjs2 uses when minifying.

I'm confused how is this different than what is already available?

Would this provide multi-stage source maps? So my uglified and concatenated r.js generated file could source map all the way back to my coffeescript?


jrburke commented Mar 24, 2013

@dbashford that is the hope. This ticket is for going from separate JS files to bundled files. Uglify can take it from bundled to minified. What is then needed is a way for transpiler plugins to participate, so .coffee to separate JS files. That will likely be worked out at least in part in this ticket for the coffeescript plugin:


jrburke commented May 11, 2013

This work was done in a branch, and did a local merge without a merge commit, finished up in bdd34e1

jrburke closed this May 11, 2013

This is awesome. Have been looking for this for a while. +100

I just updated and this is working brilliantly. This is a huge improvement for debugging production web sites. I was wondering: do you know if its possible to make this work for an additional level of indirection? Our source files are CoffeeScript and then they are compiled to JavaScript before being bundled up via requirejs. The current support allows debugging back to the compiled JavaScript files but not the CoffeeScript source files. This seems somewhat related to the require-cs issue called out above. I would guess that either uglifyjs would have to support this feature.

In case anyone is wondering why we don't use the require-cs plug-in instead of this build process, it's because it breaks our content security policy and we found that compilation times in Firefox and IE were very slow (which dramatically slowed down page load times as the amount of code we wrote increased).

Just updated Mimosa with the latest requirejs and this works like a charm.

Re: the comment above

Uglify supports being passed a source map as input, which makes it easy to go from coffee to js to mangled js while preserving the original map back to the coffee source.

But I'm not sure if it supports being passed N maps for N files that are being bundled together. It may. Not something I've looked into, but was on my short term roadmap to dig through uglify to understand how it works.


jrburke commented May 14, 2013

@derekcicerone I am hoping to wire up that leg of the source map journey, coffee-script to JS. I was planning to do that as part of jrburke/require-cs#42, and I want it to work even if that plugin does not generate the source map. A sketch:

If there is a "" file, use that as the start map for the source map chain. Hopefully the cs translation would generate that file. Ideally that map uses sourcesContent as it allows the "single file optimization" case better.

If you have and issue coffee -mc it generates foo.js and (coffee version 1.6.2).

I'd be happy to do some beta testing of this feature :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment