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

Generate source maps for bundled files #397

Closed
jrburke opened this issue Mar 6, 2013 · 9 comments
Closed

Generate source maps for bundled files #397

jrburke opened this issue Mar 6, 2013 · 9 comments
Milestone

Comments

@jrburke
Copy link
Member

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.

@dbashford
Copy link

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
Copy link
Member Author

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:
requirejs/require-cs#42

@devilankur18
Copy link

+1

@jrburke
Copy link
Member Author

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 jrburke closed this as completed May 11, 2013
@vernak2539
Copy link

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

@derekcicerone-zz
Copy link

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).

@dbashford
Copy link

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
Copy link
Member Author

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 requirejs/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 "filename.js.map" 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.

@ichernev
Copy link

If you have foo.coffee and issue coffee -mc foo.coffee it generates foo.js and foo.map (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
Labels
None yet
6 participants