From 8e603b51916426cb448a1e66e0c7156cfde719c1 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Mon, 23 Oct 2023 16:16:30 +0100 Subject: [PATCH] fix(astro): Convert SDK init file import paths to POSIX paths (#9336) Convert init file import paths to POSIX paths to ensure Vite can resolve the path to the file correctly when the import statement to inject the file into the client and browser bundles is added. --- packages/astro/src/integration/snippets.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/astro/src/integration/snippets.ts b/packages/astro/src/integration/snippets.ts index 3b732b55a330..2cf309ea1cb2 100644 --- a/packages/astro/src/integration/snippets.ts +++ b/packages/astro/src/integration/snippets.ts @@ -1,10 +1,12 @@ +import * as path from 'path'; + import type { SentryOptions } from './types'; /** * Creates a snippet that imports a Sentry.init file. */ export function buildSdkInitFileImportSnippet(filePath: string): string { - return `import "${filePath}";`; + return `import "${pathToPosix(filePath)}";`; } /** @@ -69,3 +71,7 @@ const buildClientIntegrations = (options: SentryOptions): string => { return integrations.join(', '); }; + +function pathToPosix(originalPath: string): string { + return originalPath.split(path.sep).join(path.posix.sep); +}