Skip to content

Commit

Permalink
fix(astro): prevent sentry from externalized
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Jan 2, 2024
1 parent 82d8fdb commit 0544181
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 @@ -81,6 +81,19 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => {
options.debug && console.log('[sentry-astro] 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 0544181

Please sign in to comment.