oven-sh / bun

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

could not run executable which from `bun build --compile --target=node` #10100

Open liudonghua123 opened 5 months ago

liudonghua123 commented 5 months ago

What version of Bun is running?

1.1.2

What platform is your computer?

Microsoft Windows [Version 10.0.22631.3374]

What steps can reproduce the bug?

  1. create an empty project, add @marsaud/smb2 dependences.
  2. write index.js with the following contents.

    // load the library
    import SMB2 from '@marsaud/smb2';
    
    const { USERNAME: username, PASSWORD: password, DOMAIN: domain, share: share, FILEPATH } = process.env;
    
    // https://github.com/Node-SMB/marsaud-smb2
    // create an SMB2 instance
    var smb2Client = new SMB2({
        share: share ?? String.raw`\\113.55.127.140\hp`,
        domain: domain ?? 'DOMAIN',
        username,
        password,
    });
    
    const filePath = FILEPATH ?? 'foo.txt'
    const content = await smb2Client.readFile(filePath);
    console.log(`Content of ${filePath}: ${content.toString('utf-8')}`);
    
    smb2Client.disconnect();
  3. run bun build index.js --compile --target=node --minify --outfile=out\index.exe and out\index.exe

What is the expected behavior?

The binary is executed normally.

What do you see instead?

image

Additional information

I also tried --target=bun, it's the same problem.

image

If I use ncc to build single js and then use bun to compile, it works.

image

liudonghua123 commented 5 months ago

I found `module "../messages/negotiate" come from here which is dynamic loaded, maybe it's the root issue.

image