Upgrade a Druxt site
Bump every Druxt package together, fix what the release changed, then clear the deprecation warnings the site logs.
Before you start: this guide assumes a working 0.x site. For what the version numbers promise, see Support and versioning.
Upgrade the packages
Druxt releases its packages together, so upgrade them together.
npm update won't do it: a caret range on 0.x stays inside its minor,
so ^0.24.0 never reaches 0.25.0. Install each package at its new
version instead.
1. List the Druxt packages your site has:
npm ls --depth=0 | grep druxt2. Install them at their 0.25.0 versions, with axios 0.34.0 or
later. Delete the lines for packages step 1 didn't list. With Yarn,
yarn add takes the same list.
If your site uses druxt-auth, add druxt-auth@^0.5.1 to the list.
Older releases accept only axios 0.27, and npm only warns about it
(ERESOLVE overriding peer dependency) and keeps the old one.
npm install \
druxt@^0.25.0 \
druxt-site@^0.15.0 \
druxt-entity@^0.29.0 \
druxt-router@^0.32.0 \
druxt-schema@^0.12.0 \
druxt-views@^0.23.0 \
druxt-blocks@^0.18.0 \
druxt-menu@^0.22.0 \
druxt-breadcrumb@^0.18.0 \
axios@^0.34.03. Remove vue and vuex if package.json lists them. Druxt now
uses the copies Nuxt supplies, and a second Vue stops Nuxt at startup
with a version mismatch.
npm uninstall vue vuex4. Check the install:
npm ls axios druxtYou should see axios 0.34.0 or later at the top level, one druxt with
every other entry marked deduped, and nothing marked invalid. Older
axios copies under @nuxtjs/axios or @nuxtjs/auth-next are fine. If
the tree looks different, or you use Yarn, see
"This dependency was not found: druxt".
Breaking changes
Each release's notes list its breaking changes. 0.25.0 has three.
Wrapper attributes. Druxt's own wrapper no longer adds module data
as HTML attributes, so <div entity="[object Object]" fields="[object Object]">
is now <div>. An id set on a module no longer repeats on the modules
inside it either. Find selectors and tests that matched these, and
match a class instead:
grep -rn '\[entity\]\|\[fields\]\|\[schema\]' assets components layouts pages testWrappers you write still add data they don't declare as props to their
root element. Declare the props or set inheritAttrs: false, as
Theme Druxt components
shows. Any wrapper can still read the data from $attrs.
The flicker hook. Delete any components:extend hook in
nuxt.config.js that was added to stop components flickering on first
load. Druxt fixes that itself.
DruxtField* components. The deprecated DruxtField* components
are no longer registered. Find them:
grep -rn DruxtField components layouts pagesReplace each one as its ledger entry says. To keep them working while you do, register them again:
// nuxt.config.js
export default {
druxt: {
entity: { components: { fields: true } },
},
}Clear the deprecation warnings
Deprecated APIs keep working until 2.0.0 removes them, and each use logs a warning that names its replacement. Start the site in development mode:
npm run devVisit the main pages with the browser console open, and watch the
terminal running npm run dev for warnings from the server-side
render. A warning looks like this:
[druxt] The `hash` argument for `druxt/addResource` has been deprecated,
see https://druxtjs.org/modules/druxt/deprecations#druxtstore-addresource-hashEach warning links its ledger entry, which states the replacement and the removal version:
Apply each replacement and repeat until nothing is logged.
Opt in to what 0.25.0 adds
- A server cache keeps Drupal's responses between page requests, for as
long as Drupal's
Cache-Controlallows. It holds the JSON:API index and menus, and withcache.contentthe content too: Cache Drupal responses on the Nuxt server. druxt.schema.refreshregenerates schemas after a display change in Drupal, with no rebuild: Display schemas.
Changes in 0.25.1
0.25.1 is a bug-fix release, and the install command above already picks
it up. Its behaviour changes affect only a site with its own
DruxtClient or its own proxy entries:
- A
DruxtClientyour own code creates with an axios instance inoptions.axiossends its requests through that instance'sbaseURL, so give the instance one. Before, requests went straight to the Drupal host. - With both Druxt proxies off, Druxt no longer loads
@nuxtjs/proxy. A site with its ownproxyentries adds@nuxtjs/proxytomodules.