Skip to content

Commit 8e603b5

Browse files
authored
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.
1 parent 1245e91 commit 8e603b5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/astro/src/integration/snippets.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import * as path from 'path';
2+
13
import type { SentryOptions } from './types';
24

35
/**
46
* Creates a snippet that imports a Sentry.init file.
57
*/
68
export function buildSdkInitFileImportSnippet(filePath: string): string {
7-
return `import "${filePath}";`;
9+
return `import "${pathToPosix(filePath)}";`;
810
}
911

1012
/**
@@ -69,3 +71,7 @@ const buildClientIntegrations = (options: SentryOptions): string => {
6971

7072
return integrations.join(', ');
7173
};
74+
75+
function pathToPosix(originalPath: string): string {
76+
return originalPath.split(path.sep).join(path.posix.sep);
77+
}

0 commit comments

Comments
 (0)