wallabyjs / quokka

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

Quokka + CCXT support #939

Closed Dvisacker closed 8 months ago

Dvisacker commented 8 months ago

Issue description or question

I am having an issue using the ccxt library with quokka. The script below correctly outputs the exchange object when run with node but returns an error (see screenshot) when run with quokka.

How can i configure quokka to correctly import the ccxt library ?

Sample code

const ccxt = require('ccxt')
const exchange = new ccxt.coinbase()
console.log(exchange)

Quokka.js Console Output

Screenshot 2024-03-11 at 2 53 34 AM

smcenlly commented 8 months ago

By default, Quokka uses standard-things/esm to support ESM from within commonjs files. The ccxt project is a little non-standard in its package.json configuration and is causing a problem when you load it with Quokka and are using commonjs.

You can fix this with a .quokka configuration file in your project root to disable the use of esm.

{
  "stdEsm": false
}

We are working on a fix for Quokka to accommodate the package.json exports style seen in ccxt that we expect to be available in the next day or so.

Dvisacker commented 8 months ago

Thank you @smcenlly, this worked great!