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

fix(sveltekit): Avoid top-level vite import #15371

Merged
merged 2 commits into from
Feb 11, 2025

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Feb 11, 2025

When our sentrySvelteKit vite plugin factory function is called, it needs to load the users' Vite config to determine if they enabled source map generation. This was originally implemented in #14886 for v9, because we no longer want to blindly enable source maps generation for everyone. To load the Vite config, we leverage Vite's loadConfigFromFile API. However, for this, we imported the API from vite.

As reported in #15363, this causes a cyclic require chain, which hence causes Node to error when building a SvelteKit app with Node >= 22.12.0. I think this is related to "Require ESM" being introduced in this very node version.

The workaround this PR proposes is to avoid the top-level vite import/require statement by using a dynamic import of vite instead.

@Lms24 Lms24 self-assigned this Feb 11, 2025
@Lms24 Lms24 changed the title fix(sveltekit): Avoid top-level vite import fix(sveltekit): Avoid top-level vite import Feb 11, 2025
@Lms24 Lms24 marked this pull request as ready for review February 11, 2025 12:32
@Lms24 Lms24 requested review from s1gr1d and lforst February 11, 2025 12:32
@Lms24 Lms24 merged commit 8af72f3 into develop Feb 11, 2025
32 checks passed
@Lms24 Lms24 deleted the lms/fix-sveltekit-vite-import branch February 11, 2025 15:06
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.

3 participants