Skip to content

Commit 5881009

Browse files
antonisclaude
andauthored
fix(core): Include subpath type shims in published package (#20835)
## Summary - Adds `browser.d.ts` and `server.d.ts` to the `files` list in `@sentry/core` `package.json` so they are included in the published npm tarball - Adds `typesVersions` entries for `browser` and `server` subpaths to support TypeScript < 5.0 ## Context PR [#20435](#20435) introduced `@sentry/core/browser` and `@sentry/core/server` subpath exports and added root-level `.d.ts` shim files for compatibility with TypeScript compilers that don't support the `exports` field (e.g. `moduleResolution: "node"`). However, the `.d.ts` shims were not added to the `files` list, so they were excluded from the published `10.53.0` tarball. This breaks downstream consumers like `@sentry/react-native` ([getsentry/sentry-react-native#6139](getsentry/sentry-react-native#6139)) — their TS compiler can't resolve `@sentry/core/browser`, causing `BaseTransportOptions` to become unresolvable and `ReactNativeTransportOptions` to fail the type constraint check: ``` error TS2344: Type 'ReactNativeTransportOptions' does not satisfy the constraint 'BaseTransportOptions'. Type 'ReactNativeTransportOptions' is missing the following properties from type 'BaseTransportOptions': url, recordDroppedEvent ``` ## Test plan - [ ] Verify `npm pack --dry-run` includes `browser.d.ts` and `server.d.ts` at the package root - [ ] Verify `@sentry/react-native` builds successfully against a patched `@sentry/core` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <[email protected]>
1 parent 6a7d179 commit 5881009

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

packages/core/browser.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// This file is a compatibility shim for TypeScript compilers that do not
2+
// support the package.json `exports` field for resolving subpath exports.
3+
// Note: `typesVersions` in package.json may redirect this to the downleveled variant.
4+
export * from './build/types/browser';

packages/core/package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"files": [
1313
"/build",
1414
"browser.js",
15-
"server.js"
15+
"browser.d.ts",
16+
"server.js",
17+
"server.d.ts"
1618
],
1719
"main": "build/cjs/index.js",
1820
"module": "build/esm/index.js",
@@ -54,6 +56,12 @@
5456
"<5.0": {
5557
"build/types/index.d.ts": [
5658
"build/types-ts3.8/index.d.ts"
59+
],
60+
"browser": [
61+
"build/types-ts3.8/browser.d.ts"
62+
],
63+
"server": [
64+
"build/types-ts3.8/server.d.ts"
5765
]
5866
}
5967
},

packages/core/server.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// This file is a compatibility shim for TypeScript compilers that do not
2+
// support the package.json `exports` field for resolving subpath exports.
3+
// Note: `typesVersions` in package.json may redirect this to the downleveled variant.
4+
export * from './build/types/server';

0 commit comments

Comments
 (0)