-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(nuxt): Respect user-provided source map generation settings #14020
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: some vars use sourcemap
camel-cased, others not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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):
sourcemap
nitro.rollupConfig.output.sourcemap
vite.build.sourcemap
As 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.