AlexanderPavlenko / sprockets_uglifier_with_source_maps

Create javascript source maps for your Rails applications
MIT License
35 stars 13 forks source link

Sourcemaps not used by Rollbar #6

Closed avk closed 7 years ago

avk commented 7 years ago

Hey @AlexanderPavlenko, thanks for this helpful utility. I'm having a continuous issue with Rollbar not using the default source maps the gem generates. Their support and I haven't been able to get to the bottom of it. This is their latest response:

We think the issue is your minified_url here is incorrect. Here we see: Code Version: 81961bcac73fe97447053d95a86751285a03693d Minified Url: //www.therightmargin.com/assets/public-d565741bd571b06dc302624a5b1daa1ad16b7ae0ac5d80e1e2743b930f92cb4e.js Received: 2017-01-23 02:58 pm

The minified url has /assets/public-... If I look in the corresponding .map file here you can see the source path has /assets/source/public-...

/assets/sources/public-f7cd52feeca2e7ef2a3e80aea001c2ad776eaa3e285c6774b87d077ae04cd1d3.js You just need to change the minified_url.

screen shot 2017-01-30 at 12 38 32 pm

The gem looks to be doing everything as expected, according to your example. Any thoughts on what could be the issue?

AlexanderPavlenko commented 7 years ago

Maybe they expect source map to include source code into sourcesContent field instead of referencing it in the sources fields.

avk commented 7 years ago

Yep, Rollbar confirmed it:

Aha, yes, that is true. Per our docs: "You can include the source inside the source map. We'll look for it in sourcesContent as per the source map standard."

Any thoughts on how to proceed or fix?

AlexanderPavlenko commented 7 years ago

https://github.com/AlexanderPavlenko/sprockets_uglifier_with_source_maps/tree/sources_content

You can try this version with config.assets.sourcemaps_embed_source = true.

avk commented 7 years ago

@AlexanderPavlenko thanks. I'm not seeing sourcesContent at the top of the map:

$ head -c115 public/assets/maps/application-2056d377c0539f8327c140dbd4baa97ccb98ca3dfc2526ee12f2df9533124519.js.map
{"version":3,"sources":["?"],"names":["window","goog_snippet_vars","w","google_conversion_id","google_conversion_la

but I do see the key later in the file. Is that expected?

AlexanderPavlenko commented 7 years ago

Yes, it's a hash, so the keys order is generally doesn't matter.

avk commented 7 years ago

@AlexanderPavlenko thanks, I have this working locally but doesn't seem to take in production yet. Is there anything else I may have to do besides config.assets.sourcemaps_embed_source = true in my production config?

avk commented 7 years ago

@AlexanderPavlenko this works! Would love to see this in a future release 👍

AlexanderPavlenko commented 7 years ago

Version 2.1.0 released.

coryvirok commented 7 years ago

@AlexanderPavlenko in the output @avk provided I see "sources":["?"]. I've been investigating and it appears that other UglifyJs2 users have seen this but I'm not sure I understand what the workaround is. Do you know how to get the sources list to contain the actual source filenames?

Thanks!

coryvirok commented 7 years ago

@AlexanderPavlenko any suggestions?

AlexanderPavlenko commented 7 years ago

@coryvirok assuming sources field is for URLs, original source filenames may be saved as comments inside those sources.

coryvirok commented 7 years ago

The sources field is supposed to contain the ordered list of input filenames which the source map was generated from.

E.g. If you minify and generate a source map for files a.js, b.js, c.js you will end up with out.min.js and out.min.map. The sources key in the sourcemap should contain ["a.js", "b.js", "c.js"]

The order is important here since it corresponds with the VLQ offset for which file the symbol is in. If sources == ["?"] it essentially breaks sourcemapping.

More info here: https://www.html5rocks.com/en/tutorials/developertools/sourcemaps/

But it sounds like fixing the sources key is out of scope for this library. Is that correct?