Skip to content

Commit 7f22f5d

Browse files
author
Luca Forstner
authored
fix(nextjs): Add back browser field in package.json (#6809)
1 parent 49c623f commit 7f22f5d

File tree

6 files changed

+18
-9
lines changed

6 files changed

+18
-9
lines changed

packages/nextjs/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
"engines": {
1010
"node": ">=8"
1111
},
12-
"main": "build/cjs/index.js",
13-
"module": "build/esm/index.js",
12+
"main": "build/cjs/index.server.js",
13+
"module": "build/esm/index.server.js",
14+
"browser": "build/esm/index.client.js",
1415
"types": "build/types/index.types.d.ts",
1516
"publishConfig": {
1617
"access": "public"
@@ -54,7 +55,7 @@
5455
"build:transpile:watch": "nodemon --ext ts --watch src scripts/buildRollup.ts",
5556
"build:types:watch": "tsc -p tsconfig.types.json --watch",
5657
"build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build",
57-
"circularDepCheck": "madge --circular src/index.ts && madge --circular src/client/index.ts && madge --circular src/index.types.ts",
58+
"circularDepCheck": "madge --circular src/index.client.ts && madge --circular src/edge/index.ts && madge --circular src/index.server.ts && madge --circular src/index.types.ts",
5859
"clean": "rimraf build coverage sentry-nextjs-*.tgz",
5960
"fix": "run-s fix:eslint fix:prettier",
6061
"fix:eslint": "eslint . --format stylish --fix",

packages/nextjs/rollup.npm.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default [
55
makeBaseNPMConfig({
66
// We need to include `instrumentServer.ts` separately because it's only conditionally required, and so rollup
77
// doesn't automatically include it when calculating the module dependency tree.
8-
entrypoints: ['src/index.ts', 'src/client/index.ts', 'src/edge/index.ts', 'src/config/webpack.ts'],
8+
entrypoints: ['src/index.server.ts', 'src/index.client.ts', 'src/edge/index.ts', 'src/config/webpack.ts'],
99

1010
// prevent this internal nextjs code from ending up in our built package (this doesn't happen automatially because
1111
// the name doesn't match an SDK dependency)

packages/nextjs/src/index.client.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export * from './client';
2+
3+
// This file is the main entrypoint for non-Next.js build pipelines that use
4+
// the package.json's "browser" field or the Edge runtime (Edge API routes and middleware)
5+
6+
// __SENTRY_SDK_MULTIPLEXER__

packages/nextjs/src/index.server.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export * from './config';
2+
export * from './server';
3+
4+
// This file is the main entrypoint on the server and/or when the package is `require`d
5+
6+
// __SENTRY_SDK_MULTIPLEXER__

packages/nextjs/src/index.ts

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

packages/nextjs/test/serverSdk.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { Integration } from '@sentry/types';
44
import { GLOBAL_OBJ, logger } from '@sentry/utils';
55
import * as domain from 'domain';
66

7-
import { init } from '../src/index';
7+
import { init } from '../src/server';
88

99
const { Integrations } = SentryNode;
1010

0 commit comments

Comments
 (0)