Skip to content

fix(nuxt): Chain Nuxt 5 server source maps to the original sources - #25333

Draft
s1gr1d wants to merge 1 commit into
developfrom
fix/nuxt-5-server-source-map-chaining
Draft

s1gr1d wants to merge 1 commit into
developfrom
fix/nuxt-5-server-source-map-chaining

Conversation

@s1gr1d

@s1gr1d s1gr1d commented Oct 13, 2026

Copy link
Copy Markdown
Member

On Nuxt 5, server stack frames resolve to .nuxt/vite/services/ssr/..., not to the .vue and .ts files. Nitro 3 bundles the output of the ssr build again, but it loads that output without the .map files next to it, so the final maps stop there. The module now adds a load hook to the Nitro build. For each file in <buildDir>/vite/services/ that has a .map, the hook returns the code with its map, and the bundler chains both maps. On Nuxt 3 and 4, this directory does not exist, so the hook does nothing.

This is a workaround. Nuxt has a plugin for this (SourcemapPreserverPlugin), but it adds its load hook only when Nitro does not build as a Vite environment. Its code comment says there is no second bundling pass in that mode, but there is one. When Nuxt fixes this, we can remove the hook.

The issue also asks to keep the Sentry Vite plugin out of the ssr service. No change is needed for that: @nuxt/kit 4.6 scopes addVitePlugin(..., { server: false }) to the client environment, and the existing "one debug ID per file" E2E check covers it.

The assertion in nuxt-5-sourcemaps that the server maps reach app/pages/index.vue is enabled again.

Fixes #25323

Nitro 3 bundles the output of Nuxt 5's ssr build (.nuxt/vite/services/ssr)
again, but loads it without the .map files next to it. So server stack
frames stop at that output instead of the .vue and .ts files.

Nuxt's own SourcemapPreserverPlugin does not chain the maps when Nitro
builds as a Vite environment. Until Nuxt fixes this, return each service
chunk together with its map from a load hook in the Nitro build.

Fixes #25323

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(nuxt): Nuxt 5 server source maps do not reach the original source files

1 participant