#2827 How to build Fantom program to JavaScript and run it on a JS VM?

CretinHo Sat 1 May

I use the F4 IDE. I marked my class with @Js. The generated .pod includes a helloWorld.js file and helloWorld.js.map file. I tried to feed helloWorld.js into Mozilla's Spidermonkey JS VM but it complained about sys.js being not found. In the fantom distribution directory there is no such thing as sys.js! I tried to open sys.pod to see if there is any sys.js there but these pod files seem to be not normal zip compressed archive as my helloWorld.pod file. Engrampa archive manager on Linux failed to open sys.pod because of unsupported format. It opened helloWorld.pod fine, though.

p/s: You could get the Spidermonkey JS Shell there:

https://ftp.mozilla.org/pub/firefox/releases/78.1.0esr/jsshell/

brian Sun 2 May

I tried to open sys.pod to see if there is any sys.js there but these pod files seem to be not normal zip compressed archive as my helloWorld.pod file.

Actually sys.pod is a normal zip files (all pods are).

All JS files are always compiled into each pod as a single file. So in the case of the sys JS its inside sys.pod and called "sys.js". Or in concurrent is its in the root of the concurrent.pod zip as "concurrent.js"

Also take a look at the web::FilePack class which has a whole bunch of static utility methods to extract the files you need for JS runtime to script loading into browser, filesystem, etc.

Or maybe take a look at NodeRunner where we use Node.JS to run Fantom tests in JS

Login or Signup to reply.