wallabyjs / quokka

Repository for Quokka.js questions and issues
https://quokkajs.com
1.17k stars 31 forks source link

Bun support #921

Open mheob opened 7 months ago

mheob commented 7 months ago

Issue description or question

Bun released its first stable version a few weeks ago. It is also becoming more and more popular.

When I use Quokka with Bun I get this error:

​​​​​Quokka PRO 'index.ts' (node: v20.9.0, TypeScript: v5.3.2)​​​​
 
Bun is not defined 
  ​​​​​at ​​​​​​​​readFile​​​ ​./src/utils/io.ts:2​
  ​​​​​at ​​​​​​​​readInput​​​ ​./src/utils/io.ts:8​
  ​​​​​at ​​​​​​src/day-04/index.ts:3:1

Sample code

Bun provides its API. In my case, I use Bun.file("foo.txt") to read the contents of a file.

async function readFile(filepath: string) {
    const file = Bun.file(filepath);
    const text = await file.text();
    return text.trim();
}

This is just one example of a use.

Sample repository link

The problem should be reproducible.\ But you can also try this repository for testing: https://github.com/mheob/advent-of-code-2023

Quokka.js Console Output

See the description above.

Code editor version

Visual Studio Code v1.84.2

OS name and version

OSX Sonoma (14.1.2)

OkiMusix05 commented 7 months ago

Having the same issue. Using React and Vite and I want to read the contents of a file. This is my code: const path = url; const file = Bun.file(path); const text = await file.text(); and it doesn't work. It gives me "Bun is not defined" error. I don't know if this is relevant, but I'm using OSX Monterey.

Velociraptor115 commented 6 months ago

I would also like to be able to use the Quokka extension with Bun

My primary use of Bun is for smaller scripts related to a bigger typescript repo without going through the ts transpilation step If quokka can support bun as an alternative runner, it would be great

markusstrasser commented 2 months ago

Yes, please add Bun support asap. After having tried it I won't be going back to Node