Repository navigation
vize 0.16 and Volt 0.19.4, hybrid fixes, TypeScript sources, guides, lint and CI - #8
Merged
Merged
Conversation
vize 0.15.0 keeps the set_html slot that earlier versions dropped, so v-html renders its content instead of an empty element. Its dependency range moves together with Volt 0.19, which requires vize 0.15, OXC 0.18.1, and QuickBEAM 0.11.2. Add rendering tests for v-html and for the remaining slot-ordering case from vize_ex#3, and point the README install snippet at 0.3.3.
The e2e VueRuntimeTest setup returned {:skip, reason}, which ExUnit
rejects, so a missing priv/js/reka-dialog.js failed three tests instead
of skipping them. LiveVueTest had no check and failed the same way.
Both now set a module skip tag with the command that builds the bundle.
With the bundle present, the tests run.
The Hex package listed all of priv/js, so a locally built reka-dialog.js and its Volt manifest would have been published. List the three files PhoenixVapor owns instead. Update the README install snippet and the bundle task's error message to the QuickBEAM and Volt versions mix.exs requires, move the demo to Volt 0.19 so it resolves against the path dependency again, keep the demo's port override out of the test env (its endpoint runs a server for Playwright), drop the demo's stale package-lock.json in favour of npm.lock, and re-resolve the root npm.lock.
Server actions compiled to Object.assign(__serverProps.value, ...) and triggerRef(__serverProps), neither of which exists in the generated module, so every action with a prop assignment threw a ReferenceError. The unit test asserted the broken output. Props applied after mount never re-rendered either: createApp copies a reactive root props object, so __applyProps only affected the first render. Mount through a render function that reads __propsState. Rewrite actions from the OXC AST of the compiled module instead of a hand-written brace matcher, copy the right-hand side from source instead of rebuilding it (the rebuild dropped parentheses and turned unknown nodes into undefined), accept the documented props.x = ... form, and send ref and computed values instead of Ref objects in the event params. Add e2e tests that bundle a generated module with Volt and run it in QuickBEAM.
The hybrid wrapper had no phx-update="ignore", so every server update patched the server-rendered HTML over the DOM Vue owned. The props JSON was also part of the statics, so each prop change produced a new fingerprint and LiveView resent the whole tree. Render the component inside a wrapper with fixed statics: the props JSON is a dynamic (sent only when a client prop changed) and client-owned wrappers are ignored by LiveView, which still merges their data-* attributes and calls the hook's updated(). The bridge in priv/js now applies the initial props before mounting and unmounts on destroy. The demo used a diverged copy that did neither fully and registered one of its three hybrid components; it now links the shipped bridge and registers all three. HybridUsers.vue used bare prop names in <script setup>, which are undefined in Vue, so switch it to props.users. Evaluate ref initializers once at compile time and stop the QuickBEAM runtimes used for initial state and computeds; both leaked one runtime per render.
The generated Reactive mount/3 turned every URL param key into an atom,
so any request could grow the atom table. Collect the assign keys the
template reads at compile time and assign only those params. Mounting
outside the router (:not_mounted_at_router) no longer crashes either.
Runtime sorted computeds by dependency and then rebuilt a map, which
threw the order away, so a computed that read one sorting after it
failed with a ReferenceError. Resolve names lazily through a scope
instead: computeds are lazy, so declaration order no longer matters.
Block-bodied computeds (computed(() => { ... })) were wrapped in
"return " and parsed as object literals; run them as function bodies.
Hybrid modules write <Name>.hybrid.js to assets/js/hybrid whenever the project has an assets/ directory. This repo has one, so compiling the test fixtures rewrote three tracked files on every run. Pass client_output: nil in the fixtures and untrack the generated files.
- Runtime and VueRuntime share PhoenixVapor.JS for starting, calling and stopping a QuickBEAM runtime or pooled context, instead of two copies that each kept a fallback for QuickBEAM versions before 0.11. - The <script lang="elixir"> extraction lives in PhoenixVapor.SFC instead of being copied between the server-only and hybrid paths. - The classifier's two declaration walkers are one function. - Drop the Vize 0.14 text slot workaround: vize 0.15 no longer puts the interpolated text in the statics, so it had nothing left to remove. - Drop an any_key_changed?(:all, _) clause nothing could reach. - VueRuntime no longer falls back to priv/priv/..., a path that could never exist, and reports why a bundle could not be read. - Vue's template and CSS helpers are private; public helpers called from generated code are documented instead of hidden.
mix lint runs format, warnings-as-errors, Credo, ExDNA, Reach and Dialyzer, as in vize_ex and oxc_ex. mix ci runs lint, installs the npm packages, builds the Reka bundle and runs every test tier, so the e2e tests no longer skip. CI calls the shared elixir-vibe Elixir workflow. Reach's baseline holds the String.to_atom/1 calls on names from the developer's own .vue files and OXC's patch map shape. Require Elixir 1.19, which vize 0.15 and npm already required.
Follow Volt's library workflow: - priv/ts holds reactive-runtime.ts, live-socket.ts, vapor-patch.ts and hybrid-bridge.ts. @vue/reactivity is pinned in priv/ts/package.json and vendored by mix volt.priv.vendor (setup, hex.build, hex.publish), replacing a hand-copied 3.5.30 build. Runtime bundles its code with Volt.Priv.bundle!/3 at compile time. - The root package.json exports the browser modules as phoenix_vapor, phoenix_vapor/hybrid and phoenix_vapor/vapor-patch, the way Phoenix ships its own JavaScript. patchLiveSocket lived in assets/, which the Hex package never included. - vapor-patch finds slot positions with the browser's HTML parser: the statics are joined with markers, parsed in a <template>, and each slot is read from where its marker landed. This replaces a hand-written prefix parser that, among other things, took a > inside an attribute value for the end of the tag. - mix lint runs volt.js.check --type-aware --type-check, and mix format formats the TypeScript through Volt.Formatter. tsgolint comes from the root package.json's devDependencies. - Volt is now a required, compile-time-only dependency. The manual vapor_patch_test.html page is replaced by a demo Playwright test that checks value-only diffs take the direct DOM path, and a test that the package exports resolve from deps/ and run.
- Insert scope and Vapor metadata attributes after the root tag's name
instead of before the first ">", which could sit inside an attribute
value.
- Choose the scoped CSS id and pass it to Vize instead of scraping
[data-v-...] out of the compiled CSS.
- Strip a <script lang="elixir"> block by the content range the SFC
parser reports. Searching for the first <script tag cut the wrong block
when <script setup> came first.
- Generated LiveVue callbacks raise the JavaScript error itself instead
of failing a {:ok, _} match.
- Raise on an unknown :runtime option instead of silently detecting.
- Declare Jason, which lib/ uses directly.
- ARCHITECTURE: change tracking happens per render, hybrid mode doesn't generate mount/3, the client mounts rather than hydrates, and the props JSON is a dynamic sent only when a client prop changed. - docs/hybrid-architecture.md is a design document; say so and point to ARCHITECTURE for where the implementation differs. - README: generated handle_event/3 fallbacks exist only when the module defines none. - PhoenixVapor.Vue and Hybrid.ServerCodegen moduledocs.
- Send the client every prop the template or client-side code reads. Props used only in the template were left out of data-pv-props, so the client rendered them empty after mounting. Props only server actions read stay on the server. - Read defineProps through Vize's script analysis, which covers the array, object and TypeScript forms; the script is parsed as TypeScript. - A hybrid module exports __mount(el, bridge, props) returning applyProps/unmount for that instance. Props and bridge are provided to setup as __pv instead of living in module state, so one component can be mounted several times on a page. - Templates compiled into a module (sigil, SFC, Vue.component, reactive, hybrid) parse their expressions and compute their fingerprints at compile time. A 500-row v-for renders in 0.5 ms instead of 55 ms. PhoenixVapor.render/2 still takes source templates. - Drop ServerCodegen.classify_slots/2, whose result build_rendered never used. - Scoped CSS ids come from Vize.SFC.scope_id/2.
- The package-to-global map for full-runtime bundles was hardcoded for the demo's Reka bundle, including @vueuse globals that bundle never defined. Take it as a :globals option; vue is always Vue. - VueRuntime read the bundle (800 KB for Reka UI) from disk on every mount. Cache it in :persistent_term by path, invalidated when its mtime or size changes. - The demo's direct-patching test waits for the socket to join before clicking, since clicks before that are lost.
0.3.4 widened the vize, OXC and Volt ranges; this branch requires the new versions, so its dependencies win. Its Unreleased changelog moves above the 0.3.4 section, and v-html, which 0.3.4 already renders with vize 0.15, is no longer listed as unreleased.
Follow Volt and Astral: a short README (pitch, modes, install, links), with guides for getting started and each mode, a cheatsheet, and the architecture and design documents grouped as internals. ExDoc's main page is now the README. The guides cover what the README left out: server-only .vue files, PhoenixVapor.Vue.component, components through __components__, the full runtime with :globals and the bundle task, Reactive mode's bare ref names and __params, client_output, the context pool, and that direct DOM patching applies to Reactive-mode renders.
list.filter(fun) and list.map(fun) with a function reference returned the list unchanged, and any other unrecognized method evaluated to nil, so templates rendered wrong output silently. Throw :unsupported_node so those expressions are evaluated in QuickBEAM, as arrow-function callbacks already were.
vize 0.16 stops writing LiveView attributes in vapor_split and reports events and v-models as bindings, with the position where their element's start tag ends. Renderer.compile/2 now inserts the phx-* attributes there itself (phx-<event>, and phx-change="<name>_changed" for v-model), escaping handlers. Hybrid mode compiles with events: false: Vue handles its events, and the phx-click attributes in its server HTML used to push handler source to the server before the client mounted. Also strip a <script lang="elixir"> block by the tag span vize now reports, instead of leaving an empty block. Requires vize 0.16.0. mix.lock still records 0.15 until it is released, and Volt must accept vize 0.16 before this can resolve.
The Reach baseline held 13 String.to_atom/1 calls, justified as names from the developer's own source. Several ran at render time, though, and PhoenixVapor.render/2 compiles templates at runtime, where those names can come from anywhere. - Expressions name assigns as strings; change tracking compares them with the string forms of __changed__'s keys. - Component props, the component lookup, v-for variables, and hybrid props use the existing atom when there is one, and the string otherwise. An assign key is an atom that exists, so nothing is lost. - Hybrid computeds are assigned under their string names, which is how expressions read them. - Reactive state keys become atoms when the component compiles, like its URL param keys. - Drop ScriptSetup.eval_computeds/2, which had no callers. Compile-time conversion goes through PhoenixVapor.Names.atom!/1, the one remaining baseline entry besides OXC's patch-map shape.
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.
Moves PhoenixVapor to vize 0.16 and Volt 0.19.4, and includes the fixes and cleanup from a review of the codebase. The CHANGELOG's Unreleased section lists every user-visible change.
Dependencies
vize ~> 0.16.0,oxc ~> 0.18.1andquickbeam ~> 0.11.2, locked with Volt 0.19.4, the first Volt release that accepts vize 0.16. Volt is now a required, compile-time-only dependency (see TypeScript below).priv/jswas included wholesale, so a locally builtreka-dialog.jswould have been published.Event attributes
vize 0.16's
vapor_splitno longer writesphx-*attributes. It reports events andv-modelas bindings, with the position where each element's start tag ends (elixir-volt/vize_ex#6).Renderer.compile/2now inserts PhoenixVapor's own attributes there:phx-<event>, andphx-change="<name>_changed"forv-model, with handlers escaped. Hybrid mode inserts none, because Vue handles its events; its server HTML used to carryphx-clickattributes that LiveView acted on before the client mounted.Hybrid mode fixes
__serverPropsandtriggerRef, which were never defined.createAppcopies root props.phx-update="ignore", and the props JSON is a dynamic sent only when a client prop changes, rather than part of the statics.definePropsin its object and TypeScript forms is now read, through Vize's script analysis.Refobjects instead of their values.__mount(el, bridge, props)returnsapplyProps/unmountfor that instance.Other fixes
Reactive
mount/3created atoms from URL params.Computeds failed when one read another declared after it, and block-bodied computeds didn't work in Reactive mode.
Scope and Vapor attributes could land inside an attribute value containing
>.A
<script lang="elixir">block after<script setup>leaked into the client module.Full-runtime callbacks raised
MatchErrorinstead of the JavaScript error, and a typo in:runtimewas silently ignored.Expressions using methods that aren't evaluated in Elixir fall back to QuickBEAM.
list.filter(fun)with a function reference returned the list unchanged, and methods such aspadStartrendered nothing.<script lang="elixir">blocks are stripped by the tag span vize 0.16 reports.Performance
v-forrenders in 0.5 ms instead of 55 ms.TypeScript and tooling
priv/ts, following Volt's library workflow:@vue/reactivityis pinned and vendored for Hex builds.Volt.Priv.bundle!builds the reactive runtime at compile time.package.jsonexportsphoenix_vapor,phoenix_vapor/hybridandphoenix_vapor/vapor-patch.vapor-patchuses the browser's HTML parser instead of a hand-written one.mix lintruns format, compile warnings, Credo, ExDNA, Reach, Dialyzer andvolt.js.check --type-aware --type-check, as in vize_ex and oxc_ex.mix cialso builds what the e2e tests need.Docs
The README follows Volt's shape: a pitch, the modes, install, and links. The manual moved into guides: getting started (including browser setup), templates, reactive, hybrid, full runtime, and a modes cheatsheet. The architecture and design documents are grouped as Internals.
Verification
mix ci: lint passes and 285 tests pass, including the e2e tier, on the published vize 0.16.0 and Volt 0.19.4.Related
vapor_splitreports events andv-modelas bindings.mix cifails locally attsgolintuntil the affected cache entry is cleared.