reactiverse / es4x

🚀 fast JavaScript 4 Eclipse Vert.x
https://reactiverse.io/es4x/
Apache License 2.0
877 stars 75 forks source link

Question/Requirement invoke jsdom/d3.js using es4x #565

Open rzorzorzo opened 2 years ago

rzorzorzo commented 2 years ago

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

pmlopes commented 2 years ago

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.