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 authored Jan 2, 2024
1 parent a8e2b61 commit d2e0465
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 d2e0465

Please sign in to comment.