diff --git a/packages/remix/package.json b/packages/remix/package.json index 319438487765..4ef43aa34551 100644 --- a/packages/remix/package.json +++ b/packages/remix/package.json @@ -15,7 +15,7 @@ "main": "build/cjs/index.server.js", "module": "build/esm/index.server.js", "browser": "build/esm/index.client.js", - "types": "build/types/index.server.d.ts", + "types": "build/types/index.types.d.ts", "publishConfig": { "access": "public" }, diff --git a/packages/remix/src/index.types.ts b/packages/remix/src/index.types.ts new file mode 100644 index 000000000000..0d3e8a8633a1 --- /dev/null +++ b/packages/remix/src/index.types.ts @@ -0,0 +1,30 @@ +/* eslint-disable import/export */ + +// We export everything from both the client part of the SDK and from the server part. Some of the exports collide, +// which is not allowed, unless we redifine the colliding exports in this file - which we do below. +export * from './index.client'; +export * from './index.server'; + +import type { Integration, StackParser } from '@sentry/types'; + +import * as clientSdk from './index.client'; +import * as serverSdk from './index.server'; +import { RemixOptions } from './utils/remixOptions'; + +/** Initializes Sentry Remix SDK */ +export declare function init(options: RemixOptions): void; + +// We export a merged Integrations object so that users can (at least typing-wise) use all integrations everywhere. +export const Integrations = { ...clientSdk.Integrations, ...serverSdk.Integrations }; + +export declare const defaultIntegrations: Integration[]; +export declare const defaultStackParser: StackParser; + +// This variable is not a runtime variable but just a type to tell typescript that the methods below can either come +// from the client SDK or from the server SDK. TypeScript is smart enough to understand that these resolve to the same +// methods from `@sentry/core`. +declare const runtime: 'client' | 'server'; + +export const close = runtime === 'client' ? clientSdk.close : serverSdk.close; +export const flush = runtime === 'client' ? clientSdk.flush : serverSdk.flush; +export const lastEventId = runtime === 'client' ? clientSdk.lastEventId : serverSdk.lastEventId;