es4x icon indicating copy to clipboard operation
es4x copied to clipboard

Question/Requirement invoke jsdom/d3.js using es4x

Open rzorzorzo opened this issue 3 years ago • 1 comments

Hello, I have a vertx application (java) where I would like to use d3.js to generate server side svg charts. I think that polyglot programming makes most sense if one can leverage, out of the box, existing libs.

I tested es4x for this. However this did not work as expected. I am getting many errors such as "fs module not found" (or similar). Here the js code:

jsdom = require('jsdom') d3 = require('d3')

to reproduce create an npm project, then call "npm install --save jsdom d3" create a file index.js with the above content. invoke the index.js file with es4x.

I have been able to get this to run with j2v8 nodeJS implementation. But, es4x would be a better fit for my application, as this would be a pure java application.

As a side note: with graalvm (using the experimental require feature) I am getting the similar errors as with es4x.

-- Ron

rzorzorzo avatar Dec 18 '21 14:12 rzorzorzo

Hi Ron,

In seems that d3 is trying to pull node specific modules, perhaps we need to tweak it to "think" it's running on a browser and it should work?

I think I need to prepare such a project and debug where it is calling the filesystem and see if we can avoid it.

pmlopes avatar Dec 19 '21 14:12 pmlopes