Skip to content

Upgrading to 0.14 ​

Upgrading a project from ferrovue 0.13 to 0.14: the steps to take and what behaves differently.

The CHANGELOG lists every change; this page picks out what an application notices. The steps are to bump both halves together and to generate every component again, for version 8 of generated code. The page for the release before is upgrading_to_0_13.

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.14.0

and the crate, in Cargo.toml:

toml
ferrovue = "0.14"

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.14 as well. A project that lists ferrovue@0.13.0 in pnpm's minimumReleaseAgeExclude adds ferrovue@0.14.0 beside it, and removes the 0.13.0 entry once the lockfile no longer holds it.

2. Generate every component again ​

sh
pnpm ferrovue

The 0.14 compiler writes version 8 of generated code, and mod.rs opens with ferrovue::__compat!(8). Version 8 writes the anchor of each <RouterLink> with one call of a helper the 0.13 crate lacks. The 0.14 crate supports versions 6 to 8, so a module generated by 0.13 still builds against it. The 0.13 crate stops a module of version 8 at its first line:

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

Generated renderers are shorter in other places too, so most generated files change once. What they write is the same. A CI job that runs pnpm ferrovue --check reports each module as stale until it is generated again with 0.14 and committed. See the version check.

3. Error codes your CI matches ​

These sources compiled with 0.13 and are refused with 0.14:

Source0.14
$slots read in <script setup>, where Vue defines no such nameFV0601
a member of a ref, a shallowRef or a computed other than .value read in <script setup>, such as r.lengthFV0638
an initial value in <script setup> the compiler does not translate that assigns, uses ++ or --, calls a function of setup, changes a value of setup with a method such as push, or gives a value of setup to a function of another library: const x = (n.value = 5), const y = items.value.push(z)FV0105
an initial value that runs watchEffect, watchSyncEffect or watchPostEffect: const stop = watchEffect(…)FV0103
an initial value that runs watch with immediate: const stop = watch(source, callback, { immediate: true })FV0102
an initial value that runs onServerPrefetchFV0104

0.13 read $slots as the template's $slots and a ref's member from the ref's value, and rendered state as it was before an initial value changed it. See the error codes.

Behaviour that changed ​

A <RouterLink>'s classes are merged as vue-router merges them. An active class name keeps the spaces written in it, so active-class=" on " gives class="on router-link-exact-active" where 0.13 trimmed it to on router-link-exact-active. Names that are array indices come first, and an own class equal to the link's classes is written once. See configuring the routes.

An empty TrustedHtml or InlineHtml is false ​

An empty TrustedHtml or InlineHtml prop is false in v-if, v-show, ! and ?:, as an empty string is in Vue. 0.13 took an empty one as true, so a v-if="body" over an empty body rendered the element where Vue renders <!---->. A template that relied on that renders as Vue does now. See v-html and TrustedHtml.

The location // matches the route / ​

Router::at matches the location // to the route /, as vue-router does. 0.13 matched it to a catch-all route, or to no route. A request for // now renders the home page and its links' active classes, where 0.13 rendered the catch-all or nothing. See routing.

A template's HTML comments follow the configuration ​

0.13 kept a template's HTML comments, or left them out, by the NODE_ENV of the process that ran the compiler: a plain pnpm ferrovue kept them, and the Vite plugin left them out in vite build and kept them on the dev server. 0.14 decides it from ferrovue.config.json: "comments": true keeps them, and without the key they are kept only with "isProduction": false. A component with a comment generated by a plain pnpm ferrovue renders without it now, and one whose root element had a comment beside it has a single root, which a parent's class and attributes fall through onto, as in Vue's production build. A project whose client keeps comments, with plugin-vue's template.compilerOptions.comments: true, sets "comments": true as well. See HTML comments.

Deprecated ​

linkRouter is deprecated for linkRoutes ​

linkRouter from ferrovue/link-router still works in 0.14, and is removed in a later minor release. linkRoutes from ferrovue/link-routes gives <RouterLink> and useRoute() the same answers with no router, which keeps all but <RouterLink> of vue-router out of the client bundle, in less than half the bytes of linkRouter. It takes the same routes and options, history aside, and returns a Vue plugin, given in plugins where the router was given in router:

ts
// 0.13
import { linkRouter } from "ferrovue/link-router";

const router = linkRouter(routes, { navigate, base: "/app/", location: href });
await mountIslands(islands, { router });
await renderPage(layout, islands, record, { router, previous });

// 0.14
import { linkRoutes } from "ferrovue/link-routes";

const links = linkRoutes(routes, { navigate, base: "/app/", location: href });
await mountIslands(islands, { plugins: [links] });
await renderPage(layout, islands, record, { plugins: [links], previous });

There is nothing to wait for: router.isReady() and await router.push(…) before mounting go. The page's route is links.route in place of router.currentRoute.value, and links.resolve(to) resolves a location as router.resolve(to) did. navigate is called with the same href and route as before, the link to the current page included, and an error it throws is logged with console.error, as vue-router logs a navigation error. With base left out there is no base, as on the server: linkRouter read the page's <base href> then, so a page with one gives base the value of router.base. useRouter() and $router give the members <RouterLink> reads: resolve, push, replace, options and currentRoute. An application that used any other member of the router, rendered a <RouterView>, or passed its own history, builds a vue-router of its own. See links when the application navigates on its own.