Skip to content

Commit 9bd6296

Browse files
author
Luca Forstner
authored
fix(remix): Make remix SDK type exports isomorphic (#6715)
1 parent f140888 commit 9bd6296

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

packages/remix/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"main": "build/cjs/index.server.js",
1616
"module": "build/esm/index.server.js",
1717
"browser": "build/esm/index.client.js",
18-
"types": "build/types/index.server.d.ts",
18+
"types": "build/types/index.types.d.ts",
1919
"publishConfig": {
2020
"access": "public"
2121
},

packages/remix/src/index.types.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* eslint-disable import/export */
2+
3+
// We export everything from both the client part of the SDK and from the server part. Some of the exports collide,
4+
// which is not allowed, unless we redifine the colliding exports in this file - which we do below.
5+
export * from './index.client';
6+
export * from './index.server';
7+
8+
import type { Integration, StackParser } from '@sentry/types';
9+
10+
import * as clientSdk from './index.client';
11+
import * as serverSdk from './index.server';
12+
import { RemixOptions } from './utils/remixOptions';
13+
14+
/** Initializes Sentry Remix SDK */
15+
export declare function init(options: RemixOptions): void;
16+
17+
// We export a merged Integrations object so that users can (at least typing-wise) use all integrations everywhere.
18+
export const Integrations = { ...clientSdk.Integrations, ...serverSdk.Integrations };
19+
20+
export declare const defaultIntegrations: Integration[];
21+
export declare const defaultStackParser: StackParser;
22+
23+
// This variable is not a runtime variable but just a type to tell typescript that the methods below can either come
24+
// from the client SDK or from the server SDK. TypeScript is smart enough to understand that these resolve to the same
25+
// methods from `@sentry/core`.
26+
declare const runtime: 'client' | 'server';
27+
28+
export const close = runtime === 'client' ? clientSdk.close : serverSdk.close;
29+
export const flush = runtime === 'client' ? clientSdk.flush : serverSdk.flush;
30+
export const lastEventId = runtime === 'client' ? clientSdk.lastEventId : serverSdk.lastEventId;

0 commit comments

Comments
 (0)