oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.1k stars 2.67k forks source link

@prisma/internals fails when running a build #13194

Open sukeshpabolu opened 1 month ago

sukeshpabolu commented 1 month ago

What version of Bun is running?

1.1.22-canary.96+df33f2b2a

What platform is your computer?

Microsoft Windows NT 10.0.19045.0 x64

What steps can reproduce the bug?

// install prisma internals doing bun install @prisma/internals
import { getDMMF } from "@prisma/internals";

const datamodel = `
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id           Int              @id @default(autoincrement())
  name         String?
  email        String           @unique
  profileViews Int              @default(0)
  role         Role             @default(USER)
  coinflips    Boolean[]
  posts        Post[]
  city         String
  country      String
  profile      ExtendedProfile?
  pets         Json
}

model ExtendedProfile {
  id     Int     @id @default(autoincrement())
  userId Int?    @unique
  bio    String?
  User   User?   @relation(fields: [userId], references: [id])
}

model Post {
  id        Int     @id @default(autoincrement())
  title     String
  published Boolean @default(true)
  author    User    @relation(fields: [authorId], references: [id])
  authorId  Int
  comments  Json
  views     Int     @default(0)
  likes     Int     @default(0)
}

enum Role {
  USER
  ADMIN
}
`

console.log(await getDMMF({datamodel}));

What is the expected behavior?

After doing bun build --minify --sourcemap .\src\prisma-bug.ts --target bun --outdir=out When you run ./out/prisma-bug.js it should log output of getDMMF into the console

What do you see instead?

This.

15032 | function plural(ms2, msAbs, n, name) { 15033 | var isPlural = msAbs >= n * 1.5; 15034 | return Math.round(ms2 / n) + " " + name + (isPlural ? "s" : ""); 15035 | } 15036 | var TELEMETRY_ENDPOINT_URL_PRODUCTION = "https://checkpoint.prisma.io"; 15037 | var childPath = pathdefault["default"].join(eval("dirname"), "child"); nts\code\test-co ^ ReferenceError: Can't find variable: __dirname at ../../node_modules/.pnpm/checkpoint-client@1.1.33/node_modules/checkpoint-client/dist/index.js (C:\Users\supab1\OneDrive - Inter IKEA Group\Documents\code\test-converter\node_modules\@prisma\internals\dist\chunk-4ZWDFEYP.js:15037:51) at X (C:\Users\supab1\OneDrive - Inter IKEA Group\Documents\code\test-converter\node_modules\@prisma\internals\dist\chunk-WWAWV7DQ.js:55:47) at C:\Users\supab1\OneDrive - Inter IKEA Group\Documents\code\test-converter\node_modules\@prisma\internals\dist\chunk-4ZWDFEYP.js:15898:117 at C:\Users\supab1\OneDrive - Inter IKEA Group\Documents\code\test-converter\prisma-bug\prisma-bug.js:2:625 at C:\Users\supab1\OneDrive - Inter IKEA Group\Documents\code\test-converter\node_modules\@prisma\internals\dist\index.js:134:5 at C:\Users\supab1\OneDrive - Inter IKEA Group\Documents\code\test-converter\prisma-bug\prisma-bug.js:2:625 at C:\Users\supab1\OneDrive - Inter IKEA Group\Documents\code\test-converter\src\prisma-bug.ts:1:1

Additional information

There were two issues I found one in prisma repo and one in git repo. This issue has something to do with these maybe I don't know

paperdave commented 1 month ago

image