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(sveltekit): Respect user-provided source map generation settings #14886

Merged
merged 9 commits into from
Jan 14, 2025

Conversation

s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Jan 2, 2025

Enables hidden source maps if source maps are unset. In case they are explicitly disabled or enabled the setting is kept as is.

Still need to figure out how to set filesToDeleteAfterUpload as this setting needs to be passed when "calling" the sentry Vite plugin. However, filesToDeleteAfterUpload is dependent on the Vite options and we only have access to the Vite options when creating the custom plugin.

I thought about moving this parts of this logic to the sentryVitePlugin in general.

closes #14885

@s1gr1d s1gr1d requested review from Lms24 and chargome January 2, 2025 13:54
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

I thought about moving this parts of this logic to the sentryVitePlugin in general.

This sounds reasonable to me. The base plugin's deletion behaviour is also problematic on its own as reported in #14131. I'm looking into this right now but maybe the answer really is to just handle deletion within our sentrySvelteKit Vite plugin

};
},
sentryPluginOptions?: CustomSentryVitePluginOptions,
): UserSourceMapSetting {
Copy link
Member

Choose a reason for hiding this comment

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

I see that we don't use this return value other than in tests. We'll need the return value for when we can automatically configure filesToDeleteAfterUpload, right?

packages/sveltekit/src/vite/sourceMaps.ts Outdated Show resolved Hide resolved
@s1gr1d s1gr1d self-assigned this Jan 7, 2025
@s1gr1d s1gr1d force-pushed the sig/sveltekit-sourcemaps-enabled branch from 28884c0 to cb3794e Compare January 10, 2025 15:06
@s1gr1d s1gr1d force-pushed the sig/sveltekit-sourcemaps-enabled branch from cb3794e to afc53f6 Compare January 13, 2025 13:41
@s1gr1d s1gr1d requested review from Lms24 and chargome January 13, 2025 13:43
@s1gr1d s1gr1d changed the title feat(sveltekit): Respect user-provided source map generation settings #14885 feat(sveltekit): Respect user-provided source map generation settings Jan 13, 2025
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this! Just a concern about testing. Implementation looks great to me other than two small remarks

packages/sveltekit/src/vite/sourceMaps.ts Outdated Show resolved Hide resolved
packages/sveltekit/src/vite/sourceMaps.ts Show resolved Hide resolved
packages/sveltekit/src/vite/sourceMaps.ts Outdated Show resolved Hide resolved
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.

Looks good, I would just second what Lukas said about the export for mocking sourceMapSetting!

packages/sveltekit/src/vite/sourceMaps.ts Outdated Show resolved Hide resolved
@Lms24
Copy link
Member

Lms24 commented Jan 14, 2025

Okay, I made several changes:

  • we now read the config only once and store it on globalThis._sentry_sourceMapSettings
  • this seems a bit safer to me than to store it in module scope because I'm a bit scared about recursive calls. While we can't repro them, I have a repro for a simple test plugin where an infinite recursion occurs.
  • I'm still scared of actually re-reading the vite config file we're in but let's roll with it for now. If we get reports about this causing problems, we can also change the strategy to set a flag on the global object that specifies the glob pattern and use this in the bundler plugin instead of filesToDeleteAfterUpload. Let's cross that bridge when we get to it though.
  • adjusted the tests to mock the loadConfigFromFile config and reset the global object per test
  • added the output folders which can be configured dynamically. Luckliy we're already loading the necessary config file, so it's just a matter of setting these things correctly.

I'll open a small follow-up PR to unify logging a bit more but this has a larger area than source maps, so it should be its own PR.

Copy link

codecov bot commented Jan 14, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
695 1 694 300
View the top 1 failed tests by shortest run time
client-app-routing-instrumentation.test.ts Creates a navigation transaction for app router routes
Stack Traces | 30s run time
client-app-routing-instrumentation.test.ts:19:5 Creates a navigation transaction for app router routes

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

let's merge this

@Lms24 Lms24 merged commit 2f302d7 into develop Jan 14, 2025
156 checks passed
@Lms24 Lms24 deleted the sig/sveltekit-sourcemaps-enabled branch January 14, 2025 17:44
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.

SvelteKit: Respect user-provided source map generation settings
3 participants