Skip to content

Commit

Permalink
fix(astro): Convert SDK init file import paths to POSIX paths (#9336)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Lms24 authored Oct 23, 2023
1 parent 1245e91 commit 8e603b5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/astro/src/integration/snippets.ts
Original file line number Diff line number Diff line change
@@ -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)}";`;
}

/**
Expand Down Expand Up @@ -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);
}

0 comments on commit 8e603b5

Please sign in to comment.