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

Ughhhhhhhhhhhhhhhhhhhhhh source maps #205

Closed
wants to merge 1 commit into from

Conversation

schneems
Copy link
Member

Change the default value of source maps to [1, 0] since since [0, 0] is an invalid line number.

Unfortunately even with this value it will sort circuit combine_source_maps method which is used when building coffee script source maps and sass source maps. I fixed this issue by adding a default value check. I'm not 100% sure it's the right thing to fix things.

Another potential fix is to not call this method inside of the coffee_script_processor here

map = SourceMapUtils.combine_source_maps(input[:metadata][:map], map)
and the sass processor as well. I need to investigate all of the use cases of these processors to see if that is a cleaner solution than special casing this inside of the source map utils.

Another possible solution would be as previously suggested in #203 (comment) to " replace [the default source map] with the actual source maps of the root file". This is kinda what the above solutions are doing for coffee and sass files, but falling short for non-compiled files like js and css. All in all, i'm not sure how to move forwards on that angle.

There's 4 failing tests that need to be updated, this is going to be a tough process since the values are not easily produced by another verifiable source. I'll see what I can do later.

Change the default value of source maps to `[1, 0]` since since `[0, 0]` is an invalid line number.

Unfortunately even with this value it will sort circuit `combine_source_maps` method which is used when building coffee script source maps and sass source maps. I fixed this issue by adding a default value check. I'm not 100% sure it's the right thing to fix things. 

Another potential fix is to not call this method inside of the `coffee_script_processor` here https://github.com/rails/sprockets/blob/030b7ccdea92b756aab1b8d3620cc7991d98090d/lib/sprockets/coffee_script_processor.rb#L27 and the sass processor as well. I need to investigate all of the use cases of these processors to see if that is a cleaner solution than special casing this inside of the source map utils.

Another possible solution would be as previously suggested in #203 (comment) to " replace [the default source map] with the actual source maps of the root file". This is kinda what the above solutions are doing for coffee and sass files, but falling short for non-compiled files like js and css. All in all, i'm not sure how to move forwards on that angle.

There's 4 failing tests that need to be updated, this is going to be a tough process since the values are not easily produced by another verifiable source. I'll see what I can do later.
schneems added a commit that referenced this pull request Dec 21, 2015
An alternative to #205 we don't set any sort of a "default" source map if one is already provided via another preprocessor like coffee or sass. We also set the default to be a line for line match between original and generated. 

I'm not sure why the url for babel is different test is different in `test_source_maps.rb#111` and `test_source_maps.rb#161`, or how we lost the digest on `test_source_maps.rb#L119`.

Thanks for some implementation ideas in: 9e119cd
@rafaelfranca
Copy link
Member

This can be closed now right?

@schneems schneems closed this Jan 8, 2016
@jeremy jeremy deleted the schneems/fix-concat-source-maps branch January 24, 2017 19:43
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.

2 participants