Skip to content

Commit 4e5737b

Browse files
committed
fix(sveltekit): Avoid top-level vite import
1 parent 1c7edab commit 4e5737b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/sveltekit/src/vite/sourceMaps.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { consoleSandbox, escapeStringForRegex, uuid4 } from '@sentry/core';
66
import { getSentryRelease } from '@sentry/node';
77
import type { SentryVitePluginOptions } from '@sentry/vite-plugin';
88
import { sentryVitePlugin } from '@sentry/vite-plugin';
9-
import { type Plugin, type UserConfig, loadConfigFromFile } from 'vite';
9+
import type { Plugin, UserConfig } from 'vite';
1010

1111
import MagicString from 'magic-string';
1212
import { WRAPPED_MODULE_SUFFIX } from './autoInstrument';
@@ -76,7 +76,9 @@ export async function makeCustomSentryVitePlugins(options?: CustomSentryVitePlug
7676
const defaultFileDeletionGlob = ['./.*/**/*.map', `./${adapterOutputDir}/**/*.map`];
7777

7878
if (!globalWithSourceMapSetting._sentry_sourceMapSetting) {
79-
const configFile = await loadConfigFromFile({ command: 'build', mode: 'production' });
79+
// @ts-expect-error - the dynamic import here works fine
80+
const Vite = await import('vite');
81+
const configFile = await Vite.loadConfigFromFile({ command: 'build', mode: 'production' });
8082

8183
if (configFile) {
8284
globalWithSourceMapSetting._sentry_sourceMapSetting = getUpdatedSourceMapSetting(configFile.config);

0 commit comments

Comments
 (0)