Skip to content

Commit a02e6ff

Browse files
author
Luca Forstner
authored
ref(nextjs): Replace multiplexer with conditional exports (#11442)
1 parent 6a76525 commit a02e6ff

File tree

6 files changed

+23
-60
lines changed

6 files changed

+23
-60
lines changed

packages/nextjs/package.json

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,48 @@
1111
},
1212
"main": "build/cjs/index.server.js",
1313
"module": "build/esm/index.server.js",
14-
"browser": "build/esm/index.client.js",
1514
"types": "build/types/index.types.d.ts",
1615
"exports": {
1716
"./package.json": "./package.json",
1817
".": {
18+
"edge": {
19+
"import": "./build/esm/edge/index.js",
20+
"require": "./build/cjs/edge/index.js",
21+
"default": "./build/esm/edge/index.js"
22+
},
23+
"edge-light": {
24+
"import": "./build/esm/edge/index.js",
25+
"require": "./build/cjs/edge/index.js",
26+
"default": "./build/esm/edge/index.js"
27+
},
28+
"worker": {
29+
"import": "./build/esm/edge/index.js",
30+
"require": "./build/cjs/edge/index.js",
31+
"default": "./build/esm/edge/index.js"
32+
},
33+
"workerd": {
34+
"import": "./build/esm/edge/index.js",
35+
"require": "./build/cjs/edge/index.js",
36+
"default": "./build/esm/edge/index.js"
37+
},
1938
"browser": {
2039
"import": "./build/esm/index.client.js",
2140
"require": "./build/cjs/index.client.js"
2241
},
2342
"node": "./build/cjs/index.server.js",
43+
"import": "./build/esm/index.server.js",
2444
"types": "./build/types/index.types.d.ts"
2545
},
2646
"./register": {
2747
"import": {
2848
"default": "./build/register.mjs"
2949
}
3050
},
31-
"./hook": {
51+
"./hook": {
3252
"import": {
3353
"default": "./build/hook.mjs"
3454
}
35-
}
55+
}
3656
},
3757
"typesVersions": {
3858
"<4.9": {
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export { default as valueInjectionLoader } from './valueInjectionLoader';
22
export { default as prefixLoader } from './prefixLoader';
33
export { default as wrappingLoader } from './wrappingLoader';
4-
export { default as sdkMultiplexerLoader } from './sdkMultiplexerLoader';

packages/nextjs/src/config/loaders/sdkMultiplexerLoader.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

packages/nextjs/src/config/webpack.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ import type {
2424
} from './types';
2525
import { getWebpackPluginOptions } from './webpackPluginOptions';
2626

27-
const RUNTIME_TO_SDK_ENTRYPOINT_MAP = {
28-
client: './client',
29-
server: './server',
30-
edge: './edge',
31-
} as const;
32-
3327
// Next.js runs webpack 3 times, once for the client, the server, and for edge. Because we don't want to print certain
3428
// warnings 3 times, we keep track of them here.
3529
let showedMissingGlobalErrorWarningMsg = false;
@@ -79,18 +73,6 @@ export function constructWebpackConfigFunction(
7973
// Add a loader which will inject code that sets global values
8074
addValueInjectionLoader(newConfig, userNextConfig, userSentryOptions, buildContext);
8175

82-
newConfig.module.rules.push({
83-
test: /node_modules[/\\]@sentry[/\\]nextjs/,
84-
use: [
85-
{
86-
loader: path.resolve(__dirname, 'loaders', 'sdkMultiplexerLoader.js'),
87-
options: {
88-
importTarget: RUNTIME_TO_SDK_ENTRYPOINT_MAP[runtime],
89-
},
90-
},
91-
],
92-
});
93-
9476
let pagesDirPath: string | undefined;
9577
const maybePagesDirPath = path.join(projectDir, 'pages');
9678
const maybeSrcPagesDirPath = path.join(projectDir, 'src', 'pages');

packages/nextjs/src/index.client.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,3 @@ export * from './client';
22

33
// This file is the main entrypoint for non-Next.js build pipelines that use
44
// the package.json's "browser" field or the Edge runtime (Edge API routes and middleware)
5-
6-
/**
7-
* This const serves no purpose besides being an identifier for this file that the SDK multiplexer loader can use to
8-
* determine that this is in fact a file that wants to be multiplexed.
9-
*/
10-
export const _SENTRY_SDK_MULTIPLEXER = true;

packages/nextjs/src/index.server.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
11
export * from './config';
22
export * from './server';
3-
4-
// This file is the main entrypoint on the server and/or when the package is `require`d
5-
6-
/**
7-
* This const serves no purpose besides being an identifier for this file that the SDK multiplexer loader can use to
8-
* determine that this is in fact a file that wants to be multiplexed.
9-
*/
10-
export const _SENTRY_SDK_MULTIPLEXER = true;

0 commit comments

Comments
 (0)