Skip to content

Bun fails to build @sentry/bun in cjs #17631

@aminya

Description

@aminya

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/bun

SDK Version

10.10.0

Framework Version

Bun 1.2.21

Link to Sentry event

No response

Reproduction Example/SDK Setup

Bun fails to build @sentry/bun in cjs format with the error TypeError: Expected CommonJS module to have a function wrapper. If you weren't messing around with Bun's internals, this is a bug in Bun

Steps to Reproduce

  1. Create src/index.ts with the following after installing @sentry/bun
import * as Sentry from '@sentry/bun'
  1. Bundle
bun build ./src/index.ts --outdir dist --format cjs --target bun --sourcemap
  1. Try to run run the bundle
bun ./dist/index.js

Expected Result

Should run

Actual Result

bun ./dist/index.js
 6 |     "use strict";
 7 | 
 8 |     //
 9 |     if (entry.instantiate)
10 |         return entry.instantiate;
11 |     var instantiatePromise = (async () => {
                                               ^
TypeError: Expected CommonJS module to have a function wrapper. If you weren't messing around with Bun's internals, this is a bug in Bun

Bun v1.2.21 (macOS arm64)

Additional Context

Workaround: Add --external @sentry/node to fix the issue.

Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions