-
Notifications
You must be signed in to change notification settings - Fork 792
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
Compress source maps #402
Compress source maps #402
Conversation
r? @arthurnn (@rails-bot has picked a reviewer for you, use r? to override) |
I should add, logical paths would be acceptable if the |
@@ -1106,7 +1106,7 @@ def setup | |||
end | |||
|
|||
test "digest path" do | |||
assert_equal "application.debug-2f5fde4066077205c961164247ca6ae471977d347b4ef96d9d6e2e17d9d9906c.js", | |||
assert_equal "application.debug-3fbae0574ecaa976f947b4dabdaa5975cac5011ee5196cfb5b8e464c7921314c.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are the shas changing here? I get nervous when these change in tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This digest is for an asset compiled in debug mode, which means it has a sourceMappingURL
comment which links to a source map. I think this assets digest has changed because the digest of it's source map has changed: the sources no longer contain fingerprints in their names.
This PR is introducing some errors for me, but I haven't been able to narrow down what's causing it. Source maps aren't working with index files (i.e. Consider this PR on hold until I figure out exactly what's going wrong. |
I haven't yet been able to isolate the problem I was experiencing earlier, but I discovered a new one. I made a mistake before by saying fingerprints were included in the links metadata, they're not. My test was only passing since it was broken. I've fixed the test now and verified that it is failing.
Edit: So uh, all is well again. Test was failing because the source maps weren't any different. The source files are indeed in the dependencies already so no extra work is necessary. This ordeal has been one big lesson in writing good tests. |
Where are you at here? Is this good to go? Thanks for all the work! |
This PR introduces issues for me in a large project I tested it in. I haven't been able to narrow down the source yet, just want to make sure it isn't a problem with this PR before shipping it. I'll report back here, probably today, when I figure out what is going on. |
Alright, the core of the problem seems to be with
I also foresee a larger problem to do with the mapping between sources and sprockets virtual file system. Paths outside the I'm going to have to be more cognizant of the virtual filesystem in the future. |
0c244ea
to
ce24af1
Compare
Okay, this PR's turned into a much bigger monster than originally intended. It changes a lot of stuff, here's the breakdown:
Problems:
|
There is a lot going on here, I honestly haven't been following too intently. It will be some time before I can really dig in. Are you going to be at RubyConf? |
Unfortunately, I will not. Take your time, there's still some work to be done here anyway. |
This PR is brokend atm. Some weird shenanigans are happening with caching, causing source uris to get malformed after a file is changed and recompiled. Steps to reproduce:
|
There's two separate problems here.
So basically, the solution is to do exactly the opposite of the title of this PR: move map formatting logic out of the source map processor. Each processor should call a method to format its generated map, and |
66930cd
to
328b23a
Compare
- :map metadata attribute complies with the source map v3 spec - Supports index maps - Reduced memory overhead - Improved performance
328b23a
to
386ab2b
Compare
I've fixed the tests and rebased. What I've done is created a When source maps are concatenated, No additional work is required when the source maps are saved to cache, as there are no absolute paths. I've also renamed this PR since the source map processor isn't actually doing any formatting of sources. I think this PR is finally finished... |
Thanks for all your work! |
Merged! Thanks again. |
How do you make it run guys? I get a lot of weird errors when trying to run it with current master (it worked previously for beta3): f.e. during
|
@jtomaszewski Please open up a new issue and attach an example app. |
Currently the source map processor expects sources to be in the format of a logical path, however the source map spec only supports source maps with absolute paths or relative paths. I introduced a workaround in #390 which changed logical paths to relative paths. But this solution is extremely fragile.
This PR introduces a proper fix. The source map processor now expects either relative paths, or absolute paths, and takes care of the necessary processing such that they are resolved properly. The overall effect of this is that individual processors no longer need to worry about producing sprockets compatible maps, that logic is handled by the source map processor.
This PR also removes fingerprinting from source files as reported in #343. Since the source map processor includes fingerprinted sources in the asset's metadata, it is not necessary to also include them in the data. I modified the test introduced in #367 to reflect this change.