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

Assorted Source Maps patches #255

Merged
merged 3 commits into from Feb 26, 2016
Merged

Assorted Source Maps patches #255

merged 3 commits into from Feb 26, 2016

Conversation

lucasmazza
Copy link
Contributor

This Pull Request contains 3 slightly related patches to the Source Maps support related to Babel/Sass assets.

  • 4da2114 - Fixes the source path on source maps from the BabelProcessor so the browser can request the asset original source, replacing the relative path that was used before.
  • 6ce8690 - Skip processing each source when processing the source map. This was causing issues on my app where Sprockets was getting lost on trying to load .css files as .scss ones - considering that the SourceMapProcessor already has the link value for each source, we can use it instead of (re)loading the file.
  • 34de4ea - Similar to the Babel related fix, but for Sass @imported files (the source value ends up being the absolute path for each stylesheet that was imported). I'm not 100% happy with calling resolve! + load inside the processor, but was the only way to transform the absolute file path into the source path I could think of. This patch can be easily test on a public app like Code Triage by inspecting the loaded sources. I haven't tested if the same happens with the Sassc processor, but we can duplicate the test case and see how it goes.

Let me know what makes sense/doesn't make sense of these patches, I can remove/rework any of those commits as we need.

I still believe that the source maps support here isn't 100%, as some of my exploratory tests on Google Chrome has showed some mismatches between the source contents and the positions reported by the console, but I don't have enough experience on Source Maps to rule this as an issue with the generated map or with the browser support - but I think those patches are a step forward on this.

Thanks @rafaelfranca for walking through and explaining the current implementation when debugging the first two patches with me yesterday ❤️.

…path.

This changes the `source` entry of each map to a path that can be used to get
the original source of the asset when the browser requests it through thanks to the
source map.
The sources here aren't standalone assets and don't need to properly loaded to
be added as links of the generated source map.
The original `source` values are the absolute file paths of each imported/processed
stylesheet, which must be replaced by their `source_path` counterpart so we can
serve its content to the browser.
rafaelfranca added a commit that referenced this pull request Feb 26, 2016
@rafaelfranca rafaelfranca merged commit 8824f88 into rails:master Feb 26, 2016
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.

None yet

2 participants