patrickarnett / view_component-fragment_caching Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
This is linked, as far as I can tell, to this change in rails in ActionView::PathRegistry#cast_file_system_resolvers
. As far as I can tell, this only matters in development environment, because the file watcher that triggers re-renders does not really matter in production.
In development, changes to a view component view file (e.g. app/components/some_component.html.erb
) do not trigger a re-render. changes to the compoent source code (app/components/some_component.rb
) work correctly.
I noticed it with view components that were used inside other templates (e.g. view/some_model/some_mode.html.erb
) that were themselves cached, but I think this is not related.
At load time, ViewComponent::FragmentCaching
add its resolver to ActionView. This is done in prepend_view_component_paths
:
resolver = Resolvers::ViewComponentResolver.new dir
context.prepend_view_path resolver
This is needed to add the resolver to ActionView::PathRegistry
. Before rails 7.1, adding this resolver triggered the rebuild_watcher
callback; after rails 7.1, as ActionView::PathRegistry
only calls rebuild_watcher
if a new FileSystemResolver
had to be built for the added path.
rebuild_watcher
is what sets up the filesystem watchers, in ActionView::CacheExpiry::ViewReloader
.
Adding the app/view_components
path as a regular watch path seems to fix the issue:
# config/initializers/view_component_fragment_caching.rb
ActiveSupport.on_load :action_controller do
next unless self == ActionController::Base
ActionController::Base.prepend_view_path ::ViewComponent::Base.view_component_path
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.