[Snyk] Upgrade nuxt from 3.12.4 to 4.1.0 #1252
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Snyk has created this PR to upgrade nuxt from 3.12.4 to 4.1.0.
ℹ️ Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.
The recommended version is 38 versions ahead of your current version.
The recommended version was released 23 days ago.
Issues fixed by the recommended upgrade:
SNYK-JS-BRACES-6838727
SNYK-JS-CROSSSPAWN-8303230
SNYK-JS-ES5EXT-6095076
SNYK-JS-NUXT-9486043
SNYK-JS-UNDICI-8641354
SNYK-JS-VITE-9653016
SNYK-JS-BABELHELPERS-9397697
SNYK-JS-INFLIGHT-6095116
SNYK-JS-MICROMATCH-6838728
SNYK-JS-NANOID-8492085
SNYK-JS-NANOID-8492085
SNYK-JS-NUXTVITEBUILDER-8663232
SNYK-JS-PARSEGITCONFIG-9403763
SNYK-JS-ROLLUP-8073097
SNYK-JS-VITE-8023174
SNYK-JS-VITE-8648411
SNYK-JS-VITE-9512410
SNYK-JS-VITE-9576207
SNYK-JS-VITE-9685035
SNYK-JS-VITE-9919777
SNYK-JS-BRACEEXPANSION-9789073
SNYK-JS-BRACEEXPANSION-9789073
SNYK-JS-DEVALUE-12205530
SNYK-JS-NUXT-12878602
SNYK-JS-SEND-7926862
SNYK-JS-SERVESTATIC-7926865
SNYK-JS-SIRV-12558119
SNYK-JS-UNDICI-10176064
SNYK-JS-VITE-12558116
SNYK-JS-VITE-8022916
Release notes
Package name: nuxt
👀 Highlights
🔥 Build and Performance Improvements
🍫 Enhanced Chunk Stability
Build stability has been significantly improved with import maps (#33075). This prevents cascading hash changes that could invalidate large portions of your build when small changes are made:
By default, JS chunks emitted in a Vite build are hashed, which means they can be cached immutably. However, this can cause a significant issue: a change to a single component can cause every hash to be invalidated, massively increasing the chance of 404s.
In short:
Obviously this wasn't optimal. With this new feature, the hash of (otherwise) unchanged files which import the entry won't be affected.
This feature is automatically enabled and helps maintain better cache efficiency in production. It does require native import map support, but Nuxt will automatically disable it if you have configured
vite.build.target
to include a browser that doesn't support import maps.And of course you can disable it if needed:
🦀 Experimental Rolldown Support
Nuxt now includes experimental support for
rolldown-vite
(#31812), bringing Rust-powered bundling for potentially faster builds.To try Rolldown in your Nuxt project, you need to override Vite with the rolldown-powered version since Vite is a dependency of Nuxt. Add the following to your
package.json
:npm:
pnpm:
yarn:
bun:
After adding the override, reinstall your dependencies. Nuxt will automatically detect when Rolldown is available and adjust its build configuration accordingly.
For more details on Rolldown integration, see the Vite Rolldown guide.
Note
This is experimental and may have some limitations, but offers a glimpse into the future of high-performance bundling in Nuxt.
🧪 Improved Lazy Hydration
Lazy hydration macros now work without auto-imports (#33037), making them more reliable when component auto-discovery is disabled:
This ensures that components that are not "discovered" through Nuxt (e.g., because
components
is set tofalse
in the config) can still be used in lazy hydration macros.📄 Enhanced Page Rules
If you have enabled experimental extraction of route rules, these are now exposed on a dedicated
rules
property onNuxtPage
objects (#32897), making them more accessible to modules and improving the overall architecture:The
defineRouteRules
function continues to work exactly as before, but now provides better integration possibilities for modules.🚀 Module Development Enhancements
Module Dependencies and Integration
Modules can now specify dependencies and modify options for other modules (#33063). This enables better module integration and ensures proper setup order:
This replaces the deprecated
installModule
function and provides a more robust way to handle module dependencies with version constraints and configuration merging.🪝 Module Lifecycle Hooks
Module authors now have access to two new lifecycle hooks:
onInstall
andonUpgrade
(#32397). These hooks allow modules to perform additional setup steps when first installed or when upgraded to a new version:meta: {
name: 'my-module',
version: '1.0.0',
},
onInstall(nuxt) {
// This will be run when the module is first installed
console.log('Setting up my-module for the first time!')
},
onUpgrade(inlineOptions, nuxt, previousVersion) {
// This will be run when the module is upgraded
console.log(
Upgrading my-module from v<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">previousVersion</span><span class="pl-kos">}</span></span>
)}
})
The hooks are only triggered when both
name
andversion
are provided in the module metadata. Nuxt uses the.nuxtrc
file internally to track module versions and trigger the appropriate hooks. (If you haven't come across it before, the.nuxtrc
file should be committed to version control.)Tip
This means module authors can begin implementing their own 'setup wizards' to provide a better experience when some setup is required after installing a module.
🙈 Enhanced File Resolution
The new
ignore
option forresolveFiles
(#32858) allows module authors to exclude specific files based on glob patterns:📂 Layer Directories Utility
A new
getLayerDirectories
utility (#33098) provides a clean interface for accessing layer directories without directly accessing private APIs:const layerDirs = await getLayerDirectories(nuxt)
// Access key directories:
// layerDirs.app - /app/ by default
// layerDirs.appPages - /app/pages by default
// layerDirs.server - /server by default
// layerDirs.public - /public by default
✨ Developer Experience Improvements
🎱 Simplified Kit Utilities
Several kit utilities have been improved for better developer experience:
addServerImports
now supports single imports (#32289):addServerImports([{ from: 'my-package', name: 'myUtility' }])
// Now: can pass directly
addServerImports({ from: 'my-package', name: 'myUtility' })
🔥 Performance Optimizations
This release includes several internal performance optimizations:
🐛 Notable Fixes
useFetch
hook typing (#32891)<NuxtTime>
(#32893)✅ Upgrading
As usual, our recommendation for upgrading is to run:
This will refresh your lockfile and pull in all the latest dependencies that Nuxt relies on, especially from the unjs ecosystem.
👉 Changelog
compare changes
🚀 Enhancements
ignore
option toresolveFiles
(#32858)onInstall
andonUpgrade
module hooks (#32397)rolldown-vite
(#31812)defineRouteRules
to pagerules
property (#32897)getLayerDirectories
util and refactor to use it (#33098)🔥 Performance
🩹 Fixes
satisfies
in page augmentation (#32902)useFetch
hooks (#32891)resolvePath
and normalize file extensions (#32857)requestTimeout
+ allow configuration (#32874)node_modules/
if no customsrcDir
(#32987)route
object (#32899)defineNuxtModule().with()
(#33081)nuxtApp._runningTransition
on resolve (#33025)💅 Refactors
async/await
inafterEach
(#32999)📖 Documentation
setupTimeout
and addteardownTimeout
(#32868)webRoot
to use new app directory (df7177bff)app/
directory in layer guide (eee55ea41)--nightly
command (#32907)features.inlineStyles
default value (6ff3fbebb)useRoute
and accessing route in middleware (#33004)🏡 Chore
type: 'module'
in playground (#33099)✅ Tests
import.meta.dev
(#33023)findWorkspaceDir
rather than relative paths to repo root (a6dec5bd9)expect.poll
(53fb61d5d)expect.poll
instead ofexpectWithPolling
(357492ca7)vi.waitUntil
instead of custom retry logic (611e66a47)🤖 CI
❤️ Contributors
👉 Changelog
compare changes
🔥 Performance
tinyglobby
inresolveFiles
(#32846)🩹 Fixes
error
variable (#32807)typeCheck
(#32835)null
result from webpack call (84816d8a1)reverseResolveAlias
for better errors (#32853)📖 Documentation
bun.lock
for lockfile (#32820)🏡 Chore
✅ Tests
defineNuxtComponent
out of e2e test (#32848)🤖 CI
❤️ Contributors
👉 Changelog
compare changes
🩹 Fixes
<ClientOnly>
and<DevOnly>
(#32707)defineAppConfig
type (#32760)app
context (#32758)mlly
to parse module paths (#32386)📖 Documentation
npm create nuxt@latest
(#32726).with()
(