oven-sh / bun

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

Bundling styles using postcss and autoprefixer #4896

Open rmoorman opened 1 year ago

rmoorman commented 1 year ago

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983

What platform is your computer?

Linux 5.4.0-156-generic x86_64 x86_64

What steps can reproduce the bug?

Take for example the following example repository https://github.com/rmoorman/bun-postcss-issue-20230911-example

There I created two directories, via-npm-esbuild to demonstrate the used plugin in it's default setting (node, npm, esbuild), and via-bun to try to use bun to do the same.

When node build.js is run in the via-npm-esbuild directory, the files in build are updated. The generated build/style.css file also contains a vendor prefixed version of the ::placeholder CSS rule, which shows that autoprefixer is also working through postcss.

When bun run build.js is executed in the via-bun directory, nothing is built. The logs (returned from bun's build function) mentions that there is an issue finding the style.css file though. I think that resolving the style.css file is the issue because commenting the import line in src/index.js causes the build script to successfully output something in the build directory.

What is the expected behavior?

That bun run build.js (given it is run in the via-bun directory of the example repo with all dependencies installed) will successfully bundle javascript and styles (through postcss).

What do you see instead?

No output in the configured build directory and an error in the logs:

$ bun run build.js 
{
  result: {
    outputs: [],
    success: false,
    logs: [

error: No such file or directory
/path/to/checkout/via-bun/src/index.js:1:0 0
    ]
  }
}

Additional information

It is mentioned in the docs that (even though incomplete) bun aims to support esbuild style plugins. When something is not working, the documentation also states that one should report it, so here I am, reporting my findings.

If there are any questions on how to reproduce this or anything I can do to help resolving the issue, feel free to ask, of course.

taranek commented 1 year ago

Having a similar issue, right now I get:

#19 9.035 [vite:css] Failed to load PostCSS config (searchPath: /build): [EBADF] Bad file descriptor
#19 9.035 undefined
#19 9.035 file: /build/src/assets/fonts/Poppins.css

after running bun run build which runs vite build under the hood

Maclay74 commented 12 months ago

Yep, one more here, I think the same issue with Vite and PostCSS config

bun run --bun dev
$ vite
[0.55ms] ".env"
Failed to load PostCSS config: Failed to load PostCSS config (searchPath: /frontend): [EBADF] Bad file descriptor
undefined
   code: "EBADF"
 syscall: "fstat"
   errno: -9
MickaelAustoni commented 11 months ago

Similar issue when vite build is running from oven/bun docker image.

Failed to load PostCSS config: Failed to load PostCSS config (searchPath: /app): [EBADF] Bad file descriptor
undefined
   code: "EBADF"
 syscall: "fstat"
   errno: -9
joshunrau commented 11 months ago

Same issue here with Docker:

Failed to load PostCSS config: Failed to load PostCSS config (searchPath: /root/apps/web): [EBADF] Bad file descriptor
undefined
   code: "EBADF"
 syscall: "fstat"
   errno: -9
Maclay74 commented 11 months ago

Checked 1.0.4, still doesn't work.