Skip to content

feat: serve component_vue templates from a precompiled ES module bundle#1179

Draft
maartenbreddels wants to merge 5 commits into
masterfrom
feat/vue-bundle-mode
Draft

feat: serve component_vue templates from a precompiled ES module bundle#1179
maartenbreddels wants to merge 5 commits into
masterfrom
feat/vue-bundle-mode

Conversation

@maartenbreddels

Copy link
Copy Markdown
Contributor

TLDR

@component_vue doubles 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). With SOLARA_VUE_BUNDLES=<manifest>[,...] set, component_vue resolves 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

  • Lookup by content hash: machine-independent, and a template edited after the bundle was built is a hard error ("stale bundle") instead of silent drift; never-bundled files error distinctly.
  • No bundle name on the decorator: packaging stays out of component source; hash lookup spans all configured manifests, so multiple bundles (e.g. a library shipping its own) compose without coupling.
  • Solara only generates text and checks it: running the bundler (vite, vue external) and defining the module (ipyvue.define_module, Path in dev, url in prod for versioned/preloaded/immutable serving) remain application-side.
  • Export names are c_<stem>_<hash8> — the collector also picks up templates from libraries (including solara's own component_vue usages), 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

@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>
@maartenbreddels maartenbreddels changed the title feat: serve component_vue templates from a precompiled ES module bundle FUTURE: feat: serve component_vue templates from a precompiled ES module bundle Jul 6, 2026
@maartenbreddels maartenbreddels changed the title FUTURE: feat: serve component_vue templates from a precompiled ES module bundle feat: serve component_vue templates from a precompiled ES module bundle Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant