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

Added support for source maps #42

Closed
wants to merge 2 commits into from
Closed

Added support for source maps #42

wants to merge 2 commits into from

Conversation

soluml
Copy link

@soluml soluml commented Mar 6, 2014

Added source map support for this plugin, also added documentation.

Added source map support for this plugin, also added documentation.
@soluml soluml mentioned this pull request Mar 6, 2014
@gmarty
Copy link
Owner

gmarty commented Mar 7, 2014

Thanks Benjamin.
Can you explain why do you need a special treatment for generating source map? The setting in options are passed directly to Closure Compiler interns.
What didn't work with:

grunt.initConfig({
  'closure-compiler': {
    frontend: {
      closurePath: '/src/to/closure-compiler',
      js: 'static/src/frontend.js',
      options: {
        create_source_map: 'src.map',
        source_map_format: 'V3'
      }
    }
  }
});

Updated to use options object for Source Map generation.
@soluml
Copy link
Author

soluml commented Mar 7, 2014

Thanks for your response Guillaume, I totally missed that in the documentation. Creating the maps with the options object works great! Go ahead and ignore this request.

I've modified my code to only include the "sourceMapUrl" option, which appends the sourceMapUrl comment to the end of the generated JS file which associates the two together. I have no idea why this isn't built into Closure Compiler by default, but I wasn't able to find any documentation on a flag to turn this on. I'm working in a Jenkins environment where hand editing files is a no go and this way we don't have to manage a bunch of X-SourceMap headers on the files.

I'll add a new pull request for just this code. Thanks!

@soluml soluml closed this Mar 7, 2014
@soluml
Copy link
Author

soluml commented Mar 7, 2014

Added a new pull request for just the sourceMapUrl feature: #43

Thanks again for pointing this out Guillaume!

@evenicoulddoit
Copy link

I'm using this along with the grunt watch plugin and it's adding the map to my root directory. IMO it should go into the same folder as the compiled JS.

@@ -94,6 +94,15 @@ module.exports = function(grunt) {
done(false);
}

// Check to see if we should add the source map comment to end of file
if (data.sourceMapUrl && data.options.create_source_map) {
if (typeof data.sourceMapUrl == 'boolean') data.sourceMapUrl = path.basename(data.jsOutputFile) + '.map';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't checking for "truthy", you should use if data.sourceMapUrl === true

@ChadKillingsworth
Copy link

I have no idea why this isn't built into Closure Compiler by default

I'm a Closure-compiler project maintainer. You do not need any special options - you should use the output_wrapper option that already exists on the compiler to add the source map url comment. See https://github.com/google/closure-compiler/wiki/FAQ#source-maps-and-sourcemappingurl

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

Successfully merging this pull request may close these issues.

4 participants