Skip to content

Upgrading to 0.11 ​

Upgrading a project from ferrovue 0.10 to 0.11: the steps to take, what behaves differently, and what a component may now use.

The CHANGELOG lists every change; this page picks out what an application notices. The page for the release before is upgrading_to_0_10.

Steps ​

1. Bump both halves together ​

The npm package and the crates are released together at one version, and generated code works with the crate of its own release. Bump the npm package:

sh
pnpm add -D ferrovue@^0.11.0

and the crate, in Cargo.toml:

toml
ferrovue = "0.11"

ferrovue depends on ferrovue-core, ferrovue-router and ferrovue-i18n at exactly its own version, so an application that names only ferrovue gets the other three with it. One that names any of them itself bumps it to 0.11 as well.

The npm package needs Node 22.23.4 or newer on 22, 24.22.1 or newer on 24, or 26.12.1 or newer.

2. Generate every component again ​

sh
pnpm ferrovue

The 0.11 compiler writes version 5 of generated code, and mod.rs opens with ferrovue::__compat!(5). Version 5 names what the 0.10 crate lacks: ParseUnionError, the error of the enums below, the helpers that write dates inside lists, dictionaries and interfaces, and Refused, the error of a refusal at render time. The 0.11 crate supports versions 2 to 5, so modules generated by 0.10 still build against it; generate them again all the same. The 0.10 crate supports versions 2 to 4: given a module of version 5 it stops the build at that line, with what to do:

text
error: this module was generated as version 5 of ferrovue's generated code, and this `ferrovue` crate supports versions 2 to 4: use the `ferrovue` npm package and the `ferrovue` crate of one release, and run `ferrovue` to generate the module again

A CI job that runs pnpm ferrovue --check reports each module as stale until it is generated again with 0.11 and committed. See the version check.

A setup binding or an interface's field named with $ (const $total = computed(…)) is a Rust name without it (s_total, a field total that serde still names $total), with _2 where that name is taken. 0.10 wrote s_$total, which did not build.

Every generated file changes once, also where the component did not: 0.11 names the locals of a render after the JavaScript names they hold (let sum is fv_sum, for (const r of rows) binds fv_r), where 0.10 numbered them (fv_m1, fv_a3). Only Rust identifiers change, and every render writes what it wrote. Commit the regenerated files as one change; from then on an edit to one component leaves the names of the others alone. See the locals of a render.

3. Build union props from their enums ​

A prop, or a field of an interface, typed as a union of two or more string literals is now a Rust enum the compiler generates, where 0.10 made it a Cow<'a, str>. A string enum is one too. The Rust that builds such props stops compiling at each place it passes a string, and changes as follows:

ts
// types/ui.ts
export type Size = "sm" | "md" | "lg";
vue
<!-- Button.vue -->
<script setup lang="ts">
import type { Size } from "../types/ui";
defineProps<{ size: Size; tone?: "calm" | "loud"; label: string }>();
</script>
rust
use generated::{button, types::Size};

// 0.10: button::Props::new("md", "Save").tone("loud")
let props = button::Props::new(Size::Md, "Save").tone(button::ButtonTone::Loud);

// A string that arrives at run time, from a query, a form or a database, is parsed once.
let from_query = "lg";
let props = button::Props::new(from_query.parse::<Size>()?, "Save");

A union declared with a type alias, or a string enum, keeps its name (Size, in types.rs for a .ts file); one written in place is named after its component and prop (ButtonTone), or its interface and field. Unions of string literals gives the naming of variants and the whole of the generated API: as_str(), ALL, Display, FromStr, TryFrom<&str> and serde's names of the literals. Parsing a string outside the union fails with ParseUnionError, and props that hold one in their JSON do not deserialise, fixtures included: a conformance fixture with a value TypeScript would not allow needs a member of the union.

A struct literal that set such a field to "md".into() or Cow::Borrowed("md") sets it to Size::Md. A function of the application that took the field as a &str takes props.size.as_str().

The JSON of an island, data-props and the state sent to the page are unchanged: serde writes each variant as its literal. 0.11 adds no configuration key that keeps the strings: the type error at each place a string is passed names what to change.

4. Error codes your CI matches ​

These sources compiled with 0.10 and are refused with 0.11, as TypeScript refuses them:

Source0.11
k === "z" where "z" is not a member of k's unionFV0637
a literal outside a child's union prop (size="xl"), or a string handed to itFV0515
a withDefaults default outside its unionFV0322
a constant list's field outside its interface's unionFV0215

And these unions have no enum to be:

Source0.11
a literal with no letter or digit ("+" | "-")FV0323
two literals that name one variant ("md" | "MD"), or an enum with two members of one valueFV0324
an enum named as another type of its module (interface ButtonSize beside size: "sm" | "md" in Button.vue), two .ts files declaring different unions of one name, or a union called OptionFV0325

Props named like a listener (on1, onSale), where Vue joins a child's props with mergeProps (the child is a component's root, or is given v-bind or v-on of an object beside other props):

Source0.11
such a prop given twice in the joined props, which Vue joins into a listFV0516
a required one that may be falsy there, which the child reads as undefinedFV0517
such a name passed to a component beyond its props and handed on to a child that declares itFV0502

Sources that 0.10 compiled to output Vue does not write, or to Rust that does not build, or that stopped the compiler with an error of its own, and that 0.11 refuses with a located code:

Source0.100.11
<template lang="pug">, or any lang other than htmlwrote the template's source into the pageFV0008
<template src="./x.html">rendered nothingFV0009
a prop or an interface's field with no type (defineProps<{ tag }>())a TypeErrorFV0326
defineProps<P>() or defineEmits<E>() of a type imported from another fileVue's "No fs option provided to compileScript"FV0327
a prop named with a leading $, which Vue renders as an attributeRust that does not buildFV0328
a <textarea> or an <input v-model> at a component's root, or given v-bind of an object, an attribute named at run time or a custom directiveFV0513, FV0006, FV0631 or FV0407, with no locationFV0424

Refusals that keep their meaning under another code:

Source0.100.11
a refusal inside a computed, a setup expression or a function the template callsFV0613 or FV0601, the inner code in parenthesesthe inner refusal's own code (FV0710, FV1902, FV0634, …)
an object literal whose type is not known, in the template, a computed or a functionFV0625FV0634
a loop that is neither for…of nor a counting forFV1901FV1909 (while, do…while and for…in keep FV1901)
for…of over a value that is neither a list nor a stringFV1901FV1910
a loop that carries or returns a list or an objectFV1901FV1911
a let assigned a value of another type, or starting as undefined with no typeFV1902FV1912

FV0634, FV0635 and FV0636 refuse object literals the compiler cannot build (an untyped one, one that does not match its interface, a list method of one built in place), and FV0227 a constant Map read other than with .get() and .has().

Behaviour that changed ​

Refusals at render time ​

Every component has a try_render beside its render, with the same parameters, returning Result<(), ferrovue::Refused>, so a handler that renders props from a request answers props the render cannot write as Vue writes them with 400 Bad Request. See errors_and_limits. Nothing that compiled with 0.10 stops compiling, and nothing that rendered renders differently:

  • render, html, island, into_html and into_island work as before, and Html::render_to, Html::into_string, Page::render_to and PageHole::fill too. Each has a twin that returns the refusal: try_render, Html::try_render_to, Html::try_into_string, Page::try_render_to and PageHole::try_fill.
  • What panicked as it rendered still panics where it is called without try_: a date string outside the format browsers read alike, Date.UTC() parts engines compute differently, .toISOString() of an invalid date, a .repeat() count JavaScript throws on, a date a chrono Date prop cannot hold. The message is the refusal's, error[FV1803]: components/Published.vue:3:9: the date …, where it was a message of its own: a test that expects the panic matches its code.
  • An integer beyond ±2⁶³ that the template hands a child's number prop, uses as an index or counts a v-for with was cast to i64 and rendered as 9223372036854775807, which Vue does not write. It is refused now, with FV0724: render panics on it, and try_render returns it.
  • The generated html() of a component that takes slots or render parameters returns Html<'p, Props, impl ferrovue::Renderer<Props>> where it returned impl Fn(&mut String, &Props). Code that renders it, or hands it to a Page or a Part, is unchanged.

Integers beyond ±2⁶³ ​

Integer arithmetic whose result is beyond ±2⁶³ (n * n of a large n) is written into the page as JavaScript writes it (16000000000000000000, 8.112963841460666e+31), in text, attributes, styles, template literals and String(), also when ??, ?: or || chooses it or a computed holds it. 0.10 cast it to i64 and wrote 9223372036854775807. Where the template needs it as an integer, it is refused at render time (FV0724, above).

-0 in Math.max() and Math.min() ​

Math.max() and Math.min() of integers keep a -0 that integer arithmetic gives, so 1 / Math.max(n * 0, -1) of a negative n is -Infinity, as in Vue. 0.10 compared them as i64 and wrote Infinity.

Props named like a listener ​

A child's prop named like a listener (on1, onSale) whose value is falsy (0, "", false, NaN) is left out where Vue joins the child's props with mergeProps, as Vue leaves out a listener, so the child takes the prop's default. 0.10 passed the value on: <Kid :on1="n" /> at a component's root wrote 0 where Vue writes the default. Where props are not joined, the value is passed on as before. Vue's client keeps the value at a root where its server leaves it out, so such a page mismatches as it hydrates in an app Vue renders alone too; rename the prop.

Lookups and <component :is> over a union ​

A lookup table (PAD[size]) or <component :is> read by a value of a union's enum is a match over its variants, each named, with no catch-all arm: a value outside the union cannot be built, so no arm stands for one. A key the compiler holds as a string (a computed that builds it) and an integer union keep the _ arm, which reads the union's last member.

Equality ​

size === "md" compiles to a comparison of variants, and !== too; v-if and v-else-if chains and a switch over the value follow.

FV1806 and dates inside the props ​

A Date inside a list, a dictionary or an interface of the props, and in a loader's result, which 0.10 refused with FV1806, now compiles. FV1806 refuses a Date only in Pinia state, provide, inject, a typed ref and a defineModel; a list of lists of dates is FV1810, and a dictionary of lists of dates FV0317. An island whose props hold such dates writes data-dates beside data-props, a page's record writes d beside a part's p and dates beside the layout's props, and the payload of loaders' results writes dates; the client of 0.11 reads them, and an app that reads an island's props itself passes its data-dates to reviveDates.

Newly supported ​

Dates inside lists, dictionaries and interfaces (dates_and_prices): a field at: Date, Date[], (Date | null)[], Record<string, Date> and interfaces holding them, in the props and in a loader's result, read in the template as a prop's date is and turned back into Dates in the browser from a plan the compiler writes.

Unions of string literals as enums (props): a type alias, a union in place, optional or nullable, and a string enum, generated once per module, handed between components as the enum, converted to another union that holds its members, and written in the page as its literal.

Object literals (script_logic) where their type is known: a computed or a function annotated with an interface, a .map() whose items have a known type, a child's prop typed with an interface (:item="{ id, label }"), an annotated const and satisfies, each built as the interface's Rust struct.

Loops and assignments (script_logic) in a function's or a computed's body and in a list method's callback: for…of over a list, its .entries(), Object.keys(), Object.values(), Object.entries() or a string, counting for loops, break, continue and return, and lets assigned again with =, +=, ++ and the others.

Constants and lookups: arithmetic and template literals of constants worked out when compiling (const HOUR = 60 * MINUTE), in a .ts file too; arrow functions declared inside a body; strings known to hold ASCII cut into characters and joined again; Object.hasOwn() of an object constant by a free-text key; constant Maps read with .get() and .has().

A component that renders itself by its kebab-case or camelCase name (<tree-node> or <treeNode> in TreeNode.vue), which 0.10 refused with FV0513.