Change8

v4.1.0

📦 nuxtView on GitHub →
9 features🐛 2 fixes1 deprecations🔧 9 symbols

Summary

This release introduces enhanced build stability via import maps, experimental Rolldown support, and significant improvements for module authors including new lifecycle hooks and dependency management.

Migration Steps

  1. To try Rolldown, add a package manager override for `vite` to `npm:rolldown-vite@latest` and reinstall dependencies.
  2. If using native import maps causes issues, disable it via `experimental.entryImportMap: false` in `nuxt.config.ts`.
  3. Module authors should transition from `installModule` to the `moduleDependencies` metadata field.
  4. Ensure `.nuxtrc` is committed to version control to enable `onInstall` and `onUpgrade` module hooks.

✨ New Features

  • Enhanced Chunk Stability: Automatically injected import maps in Vite builds to prevent cascading hash invalidation.
  • Experimental Rolldown Support: Integration with `rolldown-vite` for Rust-powered bundling.
  • Lazy Hydration Improvements: `defineLazyHydrationComponent` now works without auto-imports enabled.
  • Enhanced Page Rules: Route rules are now exposed via a `rules` property on `NuxtPage` objects.
  • Module Dependencies: Modules can now declare dependencies with version constraints and configuration overrides using `moduleDependencies`.
  • Module Lifecycle Hooks: Added `onInstall` and `onUpgrade` hooks for module authors.
  • Enhanced File Resolution: Added an `ignore` option to `resolveFiles` for glob-based exclusion.
  • Layer Directories Utility: New `getLayerDirectories` helper in `@nuxt/kit`.
  • Simplified Kit Utilities: `addServerImports` now supports passing a single import object instead of an array.

🐛 Bug Fixes

  • Fixed issue where changing a single component caused every JS chunk hash to be invalidated in Vite builds.
  • Fixed lazy hydration macros failing when `components: false` was configured.

🔧 Affected Symbols

defineLazyHydrationComponentNuxtPagedefineRouteRulesdefineNuxtModuleinstallModuleresolveFilesgetLayerDirectoriesaddServerImports@nuxt/kit

⚡ Deprecations

  • The `installModule` function is deprecated in favor of the new `moduleDependencies` property in `defineNuxtModule`.