Skip to content
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

Merged
merged 4 commits into from
Oct 18, 2024

Conversation

s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Oct 18, 2024

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:

export default defineNuxtConfig({
  sourcemap: {
    client: true,
  },
})

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.

@s1gr1d s1gr1d requested review from Lms24, lforst and chargome and removed request for Lms24 October 18, 2024 10:01
Copy link
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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)

Copy link
Member Author

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.

- 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- keep this setting this and
- keep this setting and


const nitroSourcemap = nitroConfig.rollupConfig.output.sourcemap;

if (nitroSourcemap === false) {
Copy link
Member

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

Copy link
Member Author

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.

nitroConfig.rollupConfig = nitroConfig.rollupConfig || {};
nitroConfig.rollupConfig.output = nitroConfig.rollupConfig.output || { sourcemap: undefined };

let previousUserSourceMapSetting: UserSourcemapSetting;
Copy link
Member

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

Copy link
Member Author

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/

@s1gr1d s1gr1d changed the title feat(nuxt): Respect user-provided sourcemap generation settings feat(nuxt): Respect user-provided source map generation settings Oct 18, 2024
@s1gr1d s1gr1d merged commit 54d286b into develop Oct 18, 2024
118 of 119 checks passed
@s1gr1d s1gr1d deleted the sig/nuxt-sourcemaps branch October 18, 2024 11:45
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.

Sourcemaps and events with debug ids are not matching
2 participants