From 3f4eb1ca62ae634c740ea16cbc4f9f7b12963f65 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 23 Jan 2023 14:57:15 +0000 Subject: [PATCH 1/2] fix(nextjs): Make SDK multiplexer more resilient --- packages/nextjs/src/config/loaders/sdkMultiplexerLoader.ts | 2 +- packages/nextjs/src/index.client.ts | 2 +- packages/nextjs/src/index.server.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/nextjs/src/config/loaders/sdkMultiplexerLoader.ts b/packages/nextjs/src/config/loaders/sdkMultiplexerLoader.ts index 9241def48a80..9373b9d0ced3 100644 --- a/packages/nextjs/src/config/loaders/sdkMultiplexerLoader.ts +++ b/packages/nextjs/src/config/loaders/sdkMultiplexerLoader.ts @@ -13,7 +13,7 @@ type LoaderOptions = { * or edge-runtime code. */ export default function sdkMultiplexerLoader(this: LoaderThis, userCode: string): string { - if (!userCode.includes('__SENTRY_SDK_MULTIPLEXER__')) { + if (!userCode.includes('_SENTRY_SDK_MULTIPLEXER')) { return userCode; } diff --git a/packages/nextjs/src/index.client.ts b/packages/nextjs/src/index.client.ts index e7ad6a8700be..cf36a30bc6af 100644 --- a/packages/nextjs/src/index.client.ts +++ b/packages/nextjs/src/index.client.ts @@ -3,4 +3,4 @@ export * from './client'; // This file is the main entrypoint for non-Next.js build pipelines that use // the package.json's "browser" field or the Edge runtime (Edge API routes and middleware) -// __SENTRY_SDK_MULTIPLEXER__ +export const _SENTRY_SDK_MULTIPLEXER = true; diff --git a/packages/nextjs/src/index.server.ts b/packages/nextjs/src/index.server.ts index 630f45ec6953..b888c3b07e19 100644 --- a/packages/nextjs/src/index.server.ts +++ b/packages/nextjs/src/index.server.ts @@ -3,4 +3,4 @@ export * from './server'; // This file is the main entrypoint on the server and/or when the package is `require`d -// __SENTRY_SDK_MULTIPLEXER__ +export const _SENTRY_SDK_MULTIPLEXER = true; From 122d1bd0ddaa215a9b0a5c532791326512835692 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 23 Jan 2023 15:09:44 +0000 Subject: [PATCH 2/2] Add comment explaining dummy const --- packages/nextjs/src/index.client.ts | 4 ++++ packages/nextjs/src/index.server.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/packages/nextjs/src/index.client.ts b/packages/nextjs/src/index.client.ts index cf36a30bc6af..c7ae01e45598 100644 --- a/packages/nextjs/src/index.client.ts +++ b/packages/nextjs/src/index.client.ts @@ -3,4 +3,8 @@ export * from './client'; // This file is the main entrypoint for non-Next.js build pipelines that use // the package.json's "browser" field or the Edge runtime (Edge API routes and middleware) +/** + * This const serves no purpose besides being an identifier for this file that the SDK multiplexer loader can use to + * determine that this is in fact a file that wants to be multiplexed. + */ export const _SENTRY_SDK_MULTIPLEXER = true; diff --git a/packages/nextjs/src/index.server.ts b/packages/nextjs/src/index.server.ts index b888c3b07e19..4a9536d25ae1 100644 --- a/packages/nextjs/src/index.server.ts +++ b/packages/nextjs/src/index.server.ts @@ -3,4 +3,8 @@ export * from './server'; // This file is the main entrypoint on the server and/or when the package is `require`d +/** + * This const serves no purpose besides being an identifier for this file that the SDK multiplexer loader can use to + * determine that this is in fact a file that wants to be multiplexed. + */ export const _SENTRY_SDK_MULTIPLEXER = true;