You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b085ece
Browse filesBrowse the repository at this point in the historyBrowse files
Resolve declared component dependencies that never opted in
`# Template Dependency: SomeComponent` is the escape hatch for component
renders static analysis can't see -- a class held in a local variable, or
reached through a helper module. `explicit_component_dependencies`
translated the declared class name into the synthetic path the component
is digested under, but only for classes `constantize_component` accepts,
which means only ones that already include `ExperimentallyCacheable`.
For anything else the raw constant name stayed in the dependency list
and was handed to the Digestor as a template path. Nothing resolves
there, so the declaration silently did nothing and the only signal was
`Couldn't find template for digesting: SomeComponent` in the log.
That defeats the point of the hatch: the dependencies you need it for
are exactly the ones whose target you may not control or want to modify.
Resolve any `ViewComponent::Base` descendant instead, and register it so
the Resolver can synthesize a template for it -- being named by a
declaration is itself the opt-in. `component_for` resolves through the
same path, since the registry can now hold components that never
included the module.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,12 @@ nav_order: 6
10
10
11
11
## main
12
12
13
+
* Resolve `# Template Dependency: SomeComponent` declarations naming a component that hasn't included `ViewComponent::ExperimentallyCacheable`.
14
+
15
+
The declaration was previously dropped: the class name was emitted to the Digestor verbatim, which looked for a template at that path, found none, and logged `Couldn't find template for digesting: SomeComponent`. That made the escape hatch unusable for exactly the dependencies it exists for, since a component reached through a local variable or a helper module is often one you don't control and can't add the module to. Naming a component in a declaration now digests it, opted in or not.
16
+
17
+
*Erik Axel Nielsen*
18
+
13
19
## 4.15.0
14
20
15
21
* Add experimental caching support, opt-in per component via `include ViewComponent::ExperimentallyCacheable`.
Copy file name to clipboardExpand all lines: docs/guide/caching.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -187,7 +187,7 @@ The same works in a template, where the branch is often the more natural place f
187
187
<%= render component.new(post: @post) %>
188
188
```
189
189
190
-
Declared components must include `ViewComponent::ExperimentallyCacheable`themselves, since a component that hasn't opted in has no digest to depend on.
190
+
A declared component doesn't have to include `ViewComponent::ExperimentallyCacheable`itself. The declaration alone gets its template, Ruby class, sidecar files, and superclasses digested, which matters because the components this escape hatch exists for are often ones you don't control.
0 commit comments