feat: serve component_vue templates from a precompiled ES module bundle#1179
Draft
maartenbreddels wants to merge 5 commits into
Draft
feat: serve component_vue templates from a precompiled ES module bundle#1179maartenbreddels wants to merge 5 commits into
maartenbreddels wants to merge 5 commits into
Conversation
@component_vue records every template it is given; `solara vue-bundle app.py` (or module names) imports the application and generates a bundler entry (one export per template) plus a manifest mapping each template's content hash to its export. With SOLARA_VUE_BUNDLES set to one or more manifests, component_vue resolves templates through them (Template(esm_module=, esm_export=), requires ipyvue with ES module support) instead of shipping the source to be compiled in the browser. Lookup is by content hash, so it is machine independent and a template edited after the bundle was built is a hard error (stale bundle) instead of silent drift. Building the bundle (vite, vue external) and defining the module (ipyvue.define_module, Path or url) remain the application's responsibility. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Each generated export wraps the component with its file-stem name (an explicit SFC name wins), keeping vue devtools and warnings readable. Howto gains the full vite workflow incl. sourcemap guidance: external map for url-served bundles, inline when file-backed (blob urls cannot resolve a relative sourceMappingURL). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
os.path.relpath emits backslashes there, which are not valid JS import paths (and failed the unit test on the windows runners). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Menu instead of c_menu_64b3100a: readable in the entry, the bundle, vue devtools and stack traces. The content hash in the name was only for uniqueness (the manifest sha1 handles staleness), so it is now only a fallback suffix for a within-bundle function-name collision (warned). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
@component_vuedoubles as a collector:solara vue-bundle app.py(modules or scripts) imports the application and generates a bundler entry (one export per template) + a manifest (content hash → export). WithSOLARA_VUE_BUNDLES=<manifest>[,...]set,component_vueresolves templates through the manifests —Template(esm_module=, esm_export=)— instead of shipping source for in-browser compilation. Unset = today's behavior, per-template hot reload intact.Design decisions
vueexternal) and defining the module (ipyvue.define_module, Path in dev, url in prod for versioned/preloaded/immutable serving) remain application-side.c_<stem>_<hash8>— the collector also picks up templates from libraries (including solara's owncomponent_vueusages), so there is no meaningful common path root.Requires ipyvue with ES module support (widgetti/ipyvue#106 vue3 / #108 1.x incl. the
Template(esm_module=)form). Unit tests cover generation, hash lookup, stale/missing errors, and the widget wiring (gated on capable ipyvue). Draft until first consumer (GrottoAI/exploration#2424) validates it end to end.🤖 Generated with Claude Code