Skip to content

Error when trying to build with Bun.build when browser is targetΒ #31

@eigilsagafos

Description

@eigilsagafos

In a project I'm working on I use Sharp in the browser. Currently we are bundling with Vite. In trying to leverage Bun build I get this error

6 | const childProcess = require('child_process');
                                 ^
error: Browser build cannot require() Node.js builtin: "child_process". To use Node.js builtins, set target to 'node' or 'bun'
    at /Users/eigilsagafos/Projects/bun-sharp-test/node_modules/detect-libc/lib/detect-libc.js:6:30

To reproduce:

index.ts

import sharp from "sharp";
sharp({});

Then run bun build index.ts --target=browser

I understand this is a problem with Bun as they are aiming for 100% Node compatibility, but it seems somewhat related to #27

(Sorry for all the edits. I created the issue by mistake before I was done πŸ˜…)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions