d2 icon indicating copy to clipboard operation
d2 copied to clipboard

d2js: doesn't support import

Open stereobooster opened this issue 11 months ago • 2 comments

First of all - I'm grateful for JS version. And it already covers a lot of my wishes.

Second - I do understand why WASM version doesn't support filesystem access out of the box.

But it would be nice to allow for nodejs package (maybe via configuration) to directly access file system

stereobooster avatar Jan 22 '25 15:01 stereobooster

Quick and dirty workaround https://github.com/stereobooster/beoe/pull/10

stereobooster avatar Jan 22 '25 17:01 stereobooster

reopening since dynamic imports still aren't supported

alixander avatar Feb 27 '25 23:02 alixander

A true streaming implementation is actually not possible. WASM to JS calls are synchronous, so to use D2's stream-on-demand import mechanism, we'd have to await some node openfile api which we can't do from WASM.

The alternative I considered is that D2.js can fake it by frontloading all the files before going into WASM, but that defeats the purpose and users can just do this themselves if that's the desired behavior.

alixander avatar Aug 12 '25 15:08 alixander