docs: add a hotswap guidelines chapter on regenerating frontend files - #25806
totally-not-ai[bot] wants to merge 6 commits into
Conversation
|
@claude review if these are actually followed in the project |
|
Claude finished @Artur-'s task in 2m 20s —— View job Review: are these practices actually followed in the project?I checked every concrete claim in
✅ Verified accurate
The Hilla-side symbols the doc names (
|
| @@ -0,0 +1,187 @@ | |||
| # Hotswap | |||
There was a problem hiding this comment.
We maybe rename this to hotswapping frontend files or similar, as there is also the other part of hotswapping of Java changes such as new routes etc. Otherwise we should make sure it covers the Java only part also
There was a problem hiding this comment.
Good point — renamed. The chapter is now guidelines/frontend-hotswap.md, titled "Hotswapping frontend files", and it opens with an explicit scope note saying the purely server-side half (route registries on a @Route change, @StyleSheet link add/remove, reflection caches, translations) is handled by other VaadinHotswapper implementations and is not covered here. The note also points out that both halves plug into the same interface and that one hotswapper often does both, RouteRegistryHotswapper being the example. That keeps the door open for a server-side chapter later without this one implying it already covers that ground.
@Artur- if you'd rather have one chapter covering both halves instead, say so and I'll fold the server-side part in here rather than scoping it out.
| and the client reaches them through a chunk keyed by class name. Updating the | ||
| imports file alone leaves the chunk wrong, so the bundle has to be rebuilt. | ||
|
|
||
| `DevLoopRedefiner.frontendDependencies(Class)` fingerprints exactly these |
There was a problem hiding this comment.
devloop is something opt-in that most do not use today - here it sounds like it is always used
There was a problem hiding this comment.
Fixed. That section now leads with the general case: nothing in the runtime hotswap path can repair a @JsModule/@Theme-style change, so what fixes it is an application restart that lets the startup tasks regenerate the imports and rebuild the bundle — in most projects today whatever restart the developer's setup already does. The dev loop is then introduced as opt-in and only active when the daemon launched the application, as the thing that detects the case and escalates automatically rather than leaving it to be noticed. The advice to extend DevLoopRedefiner.frontendDependencies when a new annotation joins that group is unchanged.
Rename to frontend-hotswap.md and state the scope up front: the server-side half of hotswap - route registries, stylesheet links, reflection caches, translations - is handled by other VaadinHotswapper implementations and is not covered here. Also describe the restart that repairs a frontend-dependency annotation change as the general case, since the vaadin-dev dev loop is opt-in and only active when the daemon launched the application.
|
Summary
Adds a guidelines chapter that explains how development-mode hotswap keeps generated frontend files (like
layouts.jsonand the Hilla endpoint clients) in sync with the Java classes they come from. It writes down the rules we already follow in the code, so the next hotswapper is written the same way.What changed
Documentation only — no code, no behavior change.
guidelines/frontend-hotswap.md, listed inguidelines/overview.md.VaadinHotswapperimplementations and is out of scope.public staticentry point that shares the private logic withexecute(), build a minimalOptionsfromVaadinService(with anullClassFinder), and unwrapExecutionFailedException. UsesTaskGenerateReactFiles.writeLayoutsandRouteRegistryHotswapperas the worked example, including how the layout-set union gates the rewrite.writeIfChanged(skips no-op writes, writes atomically so Vite never sees a half-written file), and notes that the file tracking half ofGeneratedFilesSupportdoes nothing on the hotswap path.triggerUpdate, then HMR events.EndpointGeneratorTaskFactorySPI, the implementation re-runs the whole pipeline viaEndpointCodeGenerator.update, and gates on cheap checks first.@JsModule,@JavaScript,@CssImport,@NpmPackage,@Theme— where only a restart rebuilds the bundle, and how the opt-invaadin-devdev loop detects it.