ccxt icon indicating copy to clipboard operation
ccxt copied to clipboard

CCXT will not import inside Web Worker

Open psytron opened this issue 2 years ago • 8 comments

  • OS: Mac OS Big Sur
  • Programming Language version: JavaScript Vanilla in Browser
  • CCXT version: 1.81

CCXT will not import inside Web Worker

// main.js
var w = new Worker( 'worker' , { type:'module'} ) 

// web_worker.js
import { * as ccxt } from './ccxt.browser.js';
silent fail to load  

psytron avatar May 16 '22 20:05 psytron

Hello @psytron,

Please check out this example regarding web workers' usage: https://github.com/ccxt/ccxt/tree/master/examples/html/webworker

Let me know if that does not help.

carlosmiei avatar May 16 '22 22:05 carlosmiei

Thanks @carlosmiei. That example is using old style "importScripts" and requires type:'classic'

New esm style import using Worker( {type:module } ) enable intermixing and importing new es6 modules.

psytron avatar May 17 '22 02:05 psytron

@psytron we are working on adding esm support to ccxt - see #12619, we plan to complete it later this month

frosty00 avatar May 17 '22 02:05 frosty00

In the meantime are solutions like https://esm.sh/ and https://esbuild.github.io/ recommended ?

psytron avatar May 17 '22 02:05 psytron

Is this recommended in the meantime ? https://github.com/carlosmiei/ccxt

psytron avatar May 27 '22 06:05 psytron

Since the migration of ccxt.pro into ccxt, the new browser versions (1.93.100 and higher) won't work in a webworker context anymore.

dkraemerwork avatar Oct 30 '22 17:10 dkraemerwork

Any updated thoughts on this? Enabling smooth fast UI and responsive apps would benefit tremendously from ability to offload heavy server communications like ccxt into an independent process ( web worker )

psytron avatar Jan 01 '23 20:01 psytron

Yes, its working again since the first of november actually.

dkraemerwork avatar Jan 02 '23 09:01 dkraemerwork

closing since this has been fixed

frosty00 avatar Nov 02 '23 20:11 frosty00