Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#13776 closed bug (fixed)

License comment is breaking the SourceMap

Reported by: mattrobenolt Owned by: gibson042
Priority: high Milestone: 1.10/2.0
Component: build Version: 1.9.1
Keywords: Cc: paul.irish
Blocked by: Blocking:


At the moment, the @sourceMappingURL comment is getting injected into the top of the file after the sourcemap has been generated, resulting in everything being skewed by a few lines.

I've built a tool to help detect these issues: http://sourcemap-validator.herokuapp.com/validate?url=http%3A%2F%2Fcode.jquery.com%2Fjquery-1.9.1.min.js

Change History (12)

comment:1 Changed 10 years ago by dmethvin

Component: unfiledbuild
Milestone: None1.10/2.0
Priority: undecidedhigh
Status: newopen

Thanks for catching this! An easy solution would be to put a placeholder in the file I suppose.

comment:2 Changed 10 years ago by mattrobenolt

What's the reason for it being injected at the top? It seems to be just to save a couple bytes, since there's already a block comment? As opposed to having one at the top and one at the bottom?

comment:3 Changed 10 years ago by dmethvin

See #13274 for info. If someone uses //@sourceMappingURL=... in their file it won't work in IE if conditional JS is turned on. Your tool will want to check for that.

I'd actually prefer to see a different comment sequence entirely since you can see what it requires for us to fix.

comment:4 Changed 10 years ago by mattrobenolt

Yeah, I followed along with that. Unfortunately, //@ sourceMappingURL= is hardcoded into browsers currently, so something will have to change upstream to change that sequence of characters. If we want to petition for that, I'm open.

The spec is here: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit Mailing list: https://lists.mozilla.org/listinfo/dev-js-sourcemap

FWIW, the spec also specifically says at the bottom of the document, but according to both FF and Webkit source, neither care. It can be anywhere in the document.

In my Python implementation, I explicitly check both because of jQuery. :) https://github.com/mattrobenolt/python-sourcemap/blob/master/sourcemap/__init__.py#L28-L35

comment:5 Changed 10 years ago by m_gol

Enclosing the

//@ sourceMappingURL=jquery.min.map

comment withing /* */ comment block solves the IE conditional JS compilation, doesn't it? It could be at the bottom of the file then, although it would add a few bytes, obviously.

dmethvin, where would you put this placeholder? Won't uglifyjs source map generator account for it, thus making the workaround futile?

TBH, I'd prefer browser vendors (and the spec) to accept /*@ sourceMappingURL=...*/, too. Will that fix the IE conditional compilation problem? If so, it's worth to report it on crbug.com, Chrome guys respond quite quickly to DevTools related issues.

Or maybe just the @ symbol should be changed to sth non-conflicting with IE.

comment:6 Changed 10 years ago by mattrobenolt

Backbone does what you're suggesting: http://documentcloud.github.io/backbone/backbone-min.js They just do the whole:

//@ sourceMappingURL=backbone-min.map

It feels really lame though. :( This should get pushed up to browsers before this becomes too mainstream and harder to change, in my opinion.

comment:7 Changed 10 years ago by m_gol

Cc: paul.irish added

comment:8 Changed 10 years ago by m_gol

I agree spec is not ideal here. Using IE conditional JS switches is a bad idea but unfortunately it happens.

I raised the issue here: https://groups.google.com/forum/?fromgroups=#!topic/mozilla.dev.js-sourcemap/4uo7Z5nTfUY

comment:9 Changed 10 years ago by gibson042

Owner: set to gibson042
Status: openassigned

grunt-contrib-uglify appears to ignore banner when generating maps, making them invalid for the resulting minified files. I'll try working around it on our end, but will also file a ticket there.

comment:10 Changed 10 years ago by Richard Gibson

Resolution: fixed
Status: assignedclosed

Fix #13776: Add banner before generating source map. Close gh-1246.

Changeset: 9d16fe6283667396094d49559a37fc672c06252c

comment:12 Changed 10 years ago by m_gol

This has actually been fully fixed with this bug: http://bugs.jquery.com/ticket/13793

Note: See TracTickets for help on using tickets.