feat(nuxt): Respect user-provided source map generation settings#14020
feat(nuxt): Respect user-provided source map generation settings#14020
Conversation
packages/nuxt/src/vite/sourceMaps.ts
Outdated
| export type UserSourcemapSetting = 'enabled' | 'disabled' | 'unset' | undefined; | ||
|
|
||
| /** | ||
| * Setup source maps for Sentry inside the Nuxt module during build time (in Vite for Nuxt and Rollup for N itr/** |
There was a problem hiding this comment.
| * Setup source maps for Sentry inside the Nuxt module during build time (in Vite for Nuxt and Rollup for N itr/** | |
| * Setup source maps for Sentry inside the Nuxt module during build time (in Vite for Nuxt and Rollup for Nitro) |
There was a problem hiding this comment.
oh noo that is left from biome (in WebStorm), it continuously messed up this file 😢 Especially in JSDoc and function declarations.
packages/nuxt/src/vite/sourceMaps.ts
Outdated
| - keep this setting (emit a warning that errors won't be unminified in Sentry) | ||
| - We will not upload anything | ||
| 2. users enabled source map generation (true, hidden, inline). | ||
| - keep this setting this and |
There was a problem hiding this comment.
| - keep this setting this and | |
| - keep this setting and |
packages/nuxt/src/vite/sourceMaps.ts
Outdated
|
|
||
| const nitroSourcemap = nitroConfig.rollupConfig.output.sourcemap; | ||
|
|
||
| if (nitroSourcemap === false) { |
There was a problem hiding this comment.
l: the logic in here is basically the same for vite rollup and nuxt, maybe this could be moved into a function instead
There was a problem hiding this comment.
I thought about that as it would make the code eventually shorter. But I kept the three different functions (and so the duplication) because I think it adds more complexity if those functions are combined into one. The log outputs and the sourcmap option source are different for vite, rollup and nuxt and a function abstraction would make it very difficult to read. I think it's better to have some duplication here for the purpose of readability.
packages/nuxt/src/vite/sourceMaps.ts
Outdated
| nitroConfig.rollupConfig = nitroConfig.rollupConfig || {}; | ||
| nitroConfig.rollupConfig.output = nitroConfig.rollupConfig.output || { sourcemap: undefined }; | ||
|
|
||
| let previousUserSourceMapSetting: UserSourcemapSetting; |
There was a problem hiding this comment.
l: some vars use sourcemap camel-cased, others not
There was a problem hiding this comment.
Changed all variables/comments to "source maps" and sourceMap according to https://tc39.es/source-map/
Nuxt implementation for: #13993
Fixes: #13997
In Nuxt, there are 3 places to set source maps (and all need to be enabled):
sourcemapnitro.rollupConfig.output.sourcemapvite.build.sourcemapAs Nuxt sets
sourcemap.client: false(docs here), it's not possible to determine whether this setting was set by the user or the framework. Users have to set this manually like this:With this PR, all source maps are set to
'hidden'if they were undefined before and keep the setting otherwise. This is done in 3 separate functions (one for vite, rollup and nuxt) to better distinguish between the settings.