-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
What version of Bun is running?
Bun v1.3.3 (Linux x64 baseline)
What platform is your computer?
Linux x64 (Docker container: oven/bun:1)
What steps can reproduce the bug?
- Create a Medusa.js project (e-commerce framework that uses MikroORM with decorators)
- Use the official Bun Docker image:
FROM oven/bun:1 - Run
bun install --frozen-lockfile - Run
bun run build(which internally runsmedusa build)
What is the expected behavior?
The build should complete successfully, as it does when running bun run build locally on macOS.
What do you see instead?
Build fails with a source map error:
398 | exports.originalPositionFor = (map, { line, column, bias }) => {
399 | line--;
400 | if (line < 0)
401 | throw new Error(LINE_GTR_ZERO);
402 | if (column < 0)
403 | throw new Error(COL_GTR_EQ_ZERO);
^
error: `column` must be greater than or equal to 0 (columns start at column 0)
at <anonymous> (/app/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js:403:27)
at mapSourcePosition (/app/node_modules/@cspotcode/source-map-support/source-map-support.js:415:28)
at wrapCallSite (/app/node_modules/@cspotcode/source-map-support/source-map-support.js:592:20)
at prepareStackTrace (/app/node_modules/@cspotcode/source-map-support/source-map-support.js:671:41)
at lookupPathFromDecorator (/app/node_modules/@mikro-orm/core/utils/Utils.js:657:36)
at getMetadataFromDecorator (/app/node_modules/@mikro-orm/core/metadata/MetadataStorage.js:30:95)
at <anonymous> (/app/node_modules/@mikro-orm/core/decorators/PrimaryKey.js:10:49)
at DecorateProperty (/app/node_modules/reflect-metadata/Reflect.js:561:33)
at decorate (/app/node_modules/reflect-metadata/Reflect.js:136:24)
at <anonymous> (/app/node_modules/@medusajs/utils/dist/dal/mikro-orm/base-entity.js:4:92)
Bun v1.3.3 (Linux x64 baseline)
error: script "build" exited with code 1
Additional information
Context
- Local environment (macOS):
bun run buildworks perfectly ✅ - Docker environment (Linux):
bun run buildfails with the above error ❌ - Workaround: Using Node.js in Docker works fine
Analysis
The error occurs when MikroORM's decorators (@PrimaryKey, etc.) are being processed. The stack trace shows:
- MikroORM is using decorators (TypeScript experimental feature)
@cspotcode/source-map-supporttries to map the source position@jridgewell/trace-mappingreceives an invalidcolumnvalue (< 0)
This suggests Bun's source map generation or handling when dealing with TypeScript decorators may have an issue in Docker/Linux environments.
Key Dependencies
{
"@medusajs/framework": "2.11.3",
"@medusajs/medusa": "2.11.3",
"@mikro-orm/core": "^6.x" (transitive dependency)
}Expected Behavior
Since Bun aims for Node.js compatibility and the same code works with Node.js in Docker, this should work with Bun as well.
Reproduction Repository
If needed, I can provide a minimal reproduction repository with:
- Medusa.js setup
- Dockerfile using
oven/bun:1 - Build script that triggers the error
Workaround
Currently using Node.js in Docker instead of Bun:
FROM node:20-alpine
RUN npm install
RUN npm run buildThis works, but we'd prefer to use Bun for its performance benefits.
Related Issues
This may be related to:
- Decorator handling in Bun
- Source map generation/parsing differences between Bun and Node.js
- Platform-specific differences (macOS vs Linux)
Let me know if you need any additional information or a reproduction repository!