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

Add sourceMap support to stealjs builds #103

Closed
juristr opened this issue Nov 14, 2012 · 5 comments
Closed

Add sourceMap support to stealjs builds #103

juristr opened this issue Nov 14, 2012 · 5 comments

Comments

@juristr
Copy link

juristr commented Nov 14, 2012

Hi,

it would be amazing if you guys could add support for sourceMaps in steal builds.

That's quite handy when you have to debug minimized JS files in production environments (for instance).


My insights so far
Seems like it should be integrated somewhere in the command arguments of the closure compiler in jsminify.js. Normally Google's closure compiler accepts a series of JavaScript files using multiple --js params. By then giving it the params --create_source_map and --source_map_format=V3 it'll generate an according sourcemap file which needs to be referenced in the minified file by "manually" appending

//@ sourceMappingURL=/path/to/file.js.map

As far as I understood, the current implementation of steal's build script executes a build and compression of each single JS file individually which are then appended together to the final production.js file. Hence I was not sure how to integrate support for sourcemaps as that would mean to merge them as well..

@juristr
Copy link
Author

juristr commented Nov 27, 2012

Anyone has an idea on how to potentially solve this?? I'd also be willing to submit a pull request if you guide me on how to best accomplish sourceMap support from your point of view.

@justinbmeyer
Copy link
Contributor

The issue is minification of multiple files is handled by steal and not left to be handled by the minification.

js.makePackage is what combines several files then calls minify on it:

https://github.com/bitovi/steal/blob/master/build/js/js.js#L137

Maybe we could somehow tell if source maps are supported by the minifier and allow the minifier to do it's magic.

@juristr
Copy link
Author

juristr commented Nov 27, 2012

The issue is minification of multiple files is handled by steal and not left to be handled by the minification.

In fact, that's what I noticed on my first attempt to implement this.

Maybe we could somehow tell if source maps are supported by the minifier and allow the minifier to do it's magic.

So basically you are saying that we should somehow tell steal to not call the js.makePackage and directly pass all of the source files one after the other to the minifier for making the concatenation and adding of the sourceMap support. That was my idea as well, I just didn't know whether to skip the steal package bundling could have some other side effects.

@justinbmeyer
Copy link
Contributor

Not exactly. makePackage still should be called. It makes the package after all. makePackage should work with js.minify (and js.minify with closure) to make sure sourceMap works.

For example, js.minify could take an array of sources.

The problem is that we need to add steal.executed to our files to make sure steal works with them correctly.

I'd have to investigate how to make this work with google closure.

@justinbmeyer
Copy link
Contributor

I moved this here: stealjs/steal-tools#37. Thanks!

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

No branches or pull requests

2 participants