Migrating to Root.js v2
Root.js v2 upgrades several core dependencies, including Vite, Express, Sass, and esbuild. Here's what to watch out for when upgrading an existing project.
Node.js updates
Applies to v2.0.0 and above
Support for non-LTS versions of Node.js has been dropped. Root.js v2 requires Node.js 20 or later. (Root.js v3 requires Node.js 24; see the v3 migration guide.)
Vite config updates
Applies to v2.2.0 and above
Vite has been upgraded to v7. See Vite's migration guide for the full list of changes.
Vite dropped support for the legacy Sass API. Root.js automatically translates old settings for now, but you should rename includePaths to loadPaths in root.config.ts:
⏪ Before:
// @/root.config.ts
import {defineConfig} from '@blinkk/root';
export default defineConfig({
vite: {
css: {
preprocessorOptions: {
scss: {
includePaths: [/* scss paths */],
},
},
},
},
});
⏩ After:
// @/root.config.ts
import {defineConfig} from '@blinkk/root';
export default defineConfig({
vite: {
css: {
preprocessorOptions: {
scss: {
loadPaths: [/* scss paths */],
},
},
},
},
});
Sass updates
Applies to v2.2.0 and above
Sass has been upgraded to the latest sass-embedded (v1.92.0 at the time of writing), which introduces several breaking changes.
Most notably, Sass changed how it emits mixed declarations, which can alter the order of your compiled CSS:
⏪ Before:
/* SCSS input */
.example {
color: red;
&--serious {
font-weight: bold;
}
font-weight: normal;
}
/* CSS output */
.example {
color: red;
font-weight: normal;
}
.example--serious {
font-weight: bold;
}
⏩ After:
/* SCSS input */
.example {
color: red;
&--serious {
font-weight: bold;
}
font-weight: normal;
}
/* CSS output */
.example {
color: red;
}
.example--serious {
font-weight: bold;
}
.example {
font-weight: normal;
}
CMS updates
Applies to v2.2.0 and above
Much of the CMS UI was rewritten to improve performance on large projects. That change comes with one breaking requirement: every schema.define() name must be unique across your project. This keeps the schema payload sent to the CMS and the generated root-cms.d.ts file much smaller.
❌ Bad:
/* @/components/A.schema.ts */
const Image = schema.define({
name: 'Image',
fields: [...],
});
export default schema.define(...);
/* @/components/B.schema.ts */
const Image = schema.define({
name: 'Image',
fields: [...],
});
export default schema.define(...);
✅ Good:
/* @/components/Image.schema.ts */
export default schema.define({
name: 'Image',
fields: [...],
});
/* @/components/A.schema.ts */
import Image from './Image.schema.ts';
export default schema.define(...);
/* @/components/B.schema.ts */
import Image from './Image.schema.ts';
export default schema.define(...);
Other issues
Hit an issue that isn't covered here? Open an issue on GitHub.