From d8c1748a17a1bf749ae8037493f09ae82e4c399e Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 10 Jan 2023 14:54:41 +0000 Subject: [PATCH 1/5] fix(remix): Make remix SDK type exports isomorphic --- packages/remix/package.json | 2 +- packages/remix/src/index.types.ts | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 packages/remix/src/index.types.ts 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..d1931d619550 --- /dev/null +++ b/packages/remix/src/index.types.ts @@ -0,0 +1,23 @@ +/* eslint-disable import/export */ + +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'; + +export declare function init(options: RemixOptions): void; + +export const Integrations = { ...clientSdk.Integrations, ...serverSdk.Integrations }; + +export declare const defaultIntegrations: Integration[]; +export declare const defaultStackParser: StackParser; + +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; From c6ddf9b36520db9c7b3d6eb32cd6f1c04b734b10 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 10 Jan 2023 15:05:36 +0000 Subject: [PATCH 2/5] Add some comments --- packages/remix/src/index.types.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/remix/src/index.types.ts b/packages/remix/src/index.types.ts index d1931d619550..12c5f03f5b5c 100644 --- a/packages/remix/src/index.types.ts +++ b/packages/remix/src/index.types.ts @@ -1,5 +1,7 @@ /* 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'; @@ -11,11 +13,15 @@ import { RemixOptions } from './utils/remixOptions'; 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; From 49e692732efae2c5dcecfca8e39dabfe7e697a28 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 10 Jan 2023 15:06:16 +0000 Subject: [PATCH 3/5] Add jsdoc --- packages/remix/src/index.types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/remix/src/index.types.ts b/packages/remix/src/index.types.ts index 12c5f03f5b5c..8937b8c7b00e 100644 --- a/packages/remix/src/index.types.ts +++ b/packages/remix/src/index.types.ts @@ -11,6 +11,7 @@ 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. From b7318cfc069ad0bae3651d9b35da0d032a71a394 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 10 Jan 2023 15:08:44 +0000 Subject: [PATCH 4/5] comma --- packages/remix/src/index.types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/remix/src/index.types.ts b/packages/remix/src/index.types.ts index 8937b8c7b00e..0d3e8a8633a1 100644 --- a/packages/remix/src/index.types.ts +++ b/packages/remix/src/index.types.ts @@ -1,7 +1,7 @@ /* 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. +// 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'; From 2c6f4b1700627979e290fa3a5ba2c9d2128a2287 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 10 Jan 2023 15:36:14 +0000 Subject: [PATCH 5/5] trigger stuck CI