-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
feat: make compilation stale on asset host change #364
Conversation
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.
LGTM. Just have one question.
@Judahmeek |
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.
Based on my comments, I wonder if we are testing the actual behavior of Shakapacker. In actual apps, I couldn't get any value for Shakapacker::Compiler.env
except an empty hash.
I think the problem here is that these are mincing config with env variables: What they do have is an instance of You should be able do that by adding this to
Then in the digest strategy and Also, I've not tested this but I'm pretty sure you can make this part of the digest returned by |
this needs rebasing. I merged #374 |
dc333f0
to
48a03bc
Compare
lib/shakapacker/digest_strategy.rb
Outdated
@@ -53,7 +53,12 @@ def record_compilation_digest | |||
end | |||
|
|||
def compilation_digest_path | |||
config.cache_path.join("last-compilation-digest-#{Shakapacker.env}") | |||
asset_host = Shakapacker.config.asset_host |
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.
can we try including this as part of the digest of the files themselves rather than the file path? that way the path will remain consistent and smaller, especially if in future there are other elements we decide we should be cachebusting on too
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 is a good point, and I will try to implement it.
Thanks for the suggestion.
README.md
Outdated
@@ -447,6 +447,13 @@ For more details see | |||
|
|||
If you want to use live code reloading, or you have enough JavaScript that on-demand compilation is too slow, you'll need to run `./bin/shakapacker-dev-server`. This process will watch for changes in the relevant files, defined by `shakapacker.yml` configuration settings for `source_path`, `source_entry_path`, and `additional_paths`, and it will then automatically reload the browser to match. This feature is also known as [Hot Module Replacement](https://webpack.js.org/concepts/hot-module-replacement/). | |||
|
|||
**Note:** |
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.
fwiw imo this is a bug not a feature since its reasonable to assume given how digest
works that changing the asset host would result in the digest changing, and as such doesn't require explicit documentation (similarly, I don't think it does for mtime
either because that clearly says its based on timestamps only)
@ahangarha please make changes suggested by @G-Rath! |
Regarding reviews:
|
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 is looking good to me, just needs the change to the readme removed and then should be good to go
LGTM |
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.
the readme change is still there, but happy to do a follow-up PR removing it instead of blocking this :)
51f4d6d
to
15c7a6d
Compare
Frankly, I don't know how that happened. |
README.md
Outdated
@@ -447,6 +447,8 @@ For more details see | |||
|
|||
If you want to use live code reloading, or you have enough JavaScript that on-demand compilation is too slow, you'll need to run `./bin/shakapacker-dev-server`. This process will watch for changes in the relevant files, defined by `shakapacker.yml` configuration settings for `source_path`, `source_entry_path`, and `additional_paths`, and it will then automatically reload the browser to match. This feature is also known as [Hot Module Replacement](https://webpack.js.org/concepts/hot-module-replacement/). | |||
|
|||
**Note:** If you want to enforce recompilation on asset host change (for example, through `SHAKAPACKER_ASSET_HOST` environment variable), in addition to using digest strategy, you should set `compiler_strategy_asset_host_sensitive: true` in `config/shakapacker.yml`. |
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.
@ahangarha this looks like a previous doc update that was since removed - I think it would probably be best to just do a brand new commit manually undoing the changes to the readme rather than trying to do git revert
since everything will be squashed anyway
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.
Well...
I removed it manually.
Finally... 🙂
0bed557
to
6fad55e
Compare
Summary
This PR adds a feature for making digest strategy sensitive towards asset_host change. This way, by changing
SHAKAPACKER_ASSET_HOST
, we get new asset compilation.This is an opt-in feature.
Pull Request checklist
Other Information
Closes #328