Skip to content

Commit

Permalink
fix(astro): prevent sentry from externalized (#9994)
Browse files Browse the repository at this point in the history
Fixes #9777
  • Loading branch information
anonrig committed Jan 3, 2024
1 parent d833da7 commit 55c9b98
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/astro/src/integration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => {
options.debug && logger.info('Using default server init.');
injectScript('page-ssr', buildServerSnippet(options || {}));
}

// Prevent Sentry from being externalized for SSR.
// Cloudflare like environments have Node.js APIs are available under `node:` prefix.
// Ref: https://developers.cloudflare.com/workers/runtime-apis/nodejs/
if (config?.adapter?.name.startsWith('@astro/cloudflare')) {
updateConfig({
vite: {
ssr: {
noExternal: ['@sentry/astro', '@sentry/node'],
},
},
});
}
}

const isSSR = config && (config.output === 'server' || config.output === 'hybrid');
Expand Down

0 comments on commit 55c9b98

Please sign in to comment.