Skip to content

Commit 18c0a4f

Browse files
authored
feat(bun): Add missing @sentry/node re-exports (#10396)
Add missing exports from the Node to the Bun SDK. Ignored a couple of exports that I believe aren't compatible with Bun or for which we have dedicated Bun replacements (e.g. client, transport). Node would throw ESM/CJS errors when importing from `@sentry/bun`. So let's just use Bun for this test 🙃
1 parent 0605f17 commit 18c0a4f

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,9 @@ jobs:
947947
uses: actions/setup-node@v4
948948
with:
949949
node-version-file: 'dev-packages/e2e-tests/package.json'
950+
- name: Set up Bun
951+
if: matrix.test-application == 'node-exports-test-app'
952+
uses: oven-sh/setup-bun@v1
950953
- name: Restore caches
951954
uses: ./.github/actions/restore-cache
952955
env:

dev-packages/e2e-tests/test-applications/node-exports-test-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"type": "module",
66
"scripts": {
77
"build": "tsc",
8-
"start": "pnpm build && node dist/consistentExports.js",
9-
"test": " node dist/consistentExports.js",
8+
"start": "pnpm build && bun run ./dist/consistentExports.js",
9+
"test": " bun run ./dist/consistentExports.js",
1010
"clean": "npx rimraf node_modules,pnpm-lock.yaml,dist",
1111
"test:build": "pnpm install && pnpm build",
1212
"test:assert": "pnpm test"

dev-packages/e2e-tests/test-applications/node-exports-test-app/scripts/consistentExports.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as SentryAstro from '@sentry/astro';
2-
// import * as SentryBun from '@sentry/bun';
2+
import * as SentryBun from '@sentry/bun';
33
import * as SentryNextJs from '@sentry/nextjs';
44
import * as SentryNode from '@sentry/node';
55
import * as SentryRemix from '@sentry/remix';
@@ -36,6 +36,17 @@ const DEPENDENTS: Dependent[] = [
3636
package: '@sentry/astro',
3737
exports: Object.keys(SentryAstro),
3838
},
39+
{
40+
package: '@sentry/bun',
41+
exports: Object.keys(SentryBun),
42+
ignoreExports: [
43+
// not supported in bun:
44+
'Handlers',
45+
'NodeClient',
46+
'hapiErrorPlugin',
47+
'makeNodeTransport',
48+
],
49+
},
3950
{
4051
package: '@sentry/nextjs',
4152
// Next.js doesn't require explicit exports, so we can just merge top level and `default` exports:

packages/bun/src/index.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,22 @@ export {
8989
parameterize,
9090
} from '@sentry/core';
9191
export type { SpanStatusType } from '@sentry/core';
92-
export { autoDiscoverNodePerformanceMonitoringIntegrations, cron } from '@sentry/node';
92+
export {
93+
// eslint-disable-next-line deprecation/deprecation
94+
deepReadDirSync,
95+
// eslint-disable-next-line deprecation/deprecation
96+
enableAnrDetection,
97+
// eslint-disable-next-line deprecation/deprecation
98+
getModuleFromFilename,
99+
DEFAULT_USER_INCLUDES,
100+
autoDiscoverNodePerformanceMonitoringIntegrations,
101+
cron,
102+
createGetModuleFromFilename,
103+
defaultStackParser,
104+
extractRequestData,
105+
getSentryRelease,
106+
addRequestDataToEvent,
107+
} from '@sentry/node';
93108

94109
export { BunClient } from './client';
95110
export {

0 commit comments

Comments
 (0)