oven-sh / bun

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

"bun build" does not embed binaries from node_modules correctly #15374

Open buzzy opened 1 week ago

buzzy commented 1 week ago

What version of Bun is running?

1.1.36+ededc168c

What platform is your computer?

Linux 6.1.0-9-amd64 x86_64 x86_64

What steps can reproduce the bug?

  1. Install sharp - https://github.com/lovell/sharp
    bun install sharp
  2. import and use the sharp library
    const sharp = require('sharp');
    const semiTransparentRedPng = await sharp({
    create: {
    width: 48,
    height: 48,
    channels: 4,
    background: { r: 255, g: 0, b: 0, alpha: 0.5 }
    }
    })
    .png()
    .toBuffer();
  3. Compile a binary with bun build
    bun build --compile --minify --smol --sourcemap index.ts --outfile test
  4. Run the "test" binary in the current directory that also has the node_modules directory. It will work
    ./test
  5. Copy the "test" file to another directory and run it. It will fail, as it does not find node_modules dir
    cp test /tmp
    /tmp/test

What is the expected behavior?

That the resulting binary from "bun build" will include all necessary files, including potential binaries found in node_modules.

What do you see instead?

The resulting binary from "bun build" is trying to run external binaries in node_modules.

Additional information

No response

calumk commented 5 days ago

Related :

https://github.com/oven-sh/bun/issues/8967#issuecomment-2501343823