Skip to content

Commit

Permalink
fix(nextjs): Export Replay from index.server.ts to avoid TS error (#…
Browse files Browse the repository at this point in the history
…6577)

This patch fixes a TypeScript error when using the `Replay` integration exported from the NextJS SDK (>= 7.27.0). Because our SDK tells TS that it should import types from `index.server.ts`, TS doesn't find the Replay integration class although it's correctly exported from `indext.client.ts`. 

Note: even without this change, Replay works in NextJS, it just fixes just a TS error.
  • Loading branch information
Lms24 authored Dec 19, 2022
1 parent 2fa11eb commit 6a275c0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/nextjs/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import { addOrUpdateIntegration, IntegrationWithExclusionOption } from './utils/
export * from '@sentry/node';
export { captureUnderscoreErrorException } from './utils/_error';

// Exporting the Replay integration also from index.server.ts because TS only recognizes types from index.server.ts
// If we didn't export this, TS would complain that it can't find `Sentry.Replay` in the package,
// causing a build failure, when users initialize Replay in their sentry.client.config.js/ts file.
export { Replay } from './index.client';

// Here we want to make sure to only include what doesn't have browser specifics
// because or SSR of next.js we can only use this.
export { ErrorBoundary, showReportDialog, withErrorBoundary } from '@sentry/react';
Expand Down

0 comments on commit 6a275c0

Please sign in to comment.