rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

Support running `rescript` in non-node environments

Open tom-sherman opened this issue 3 years ago • 2 comments

This is a similar feature request to #4965 but more general.

ReScript isn't a node-only language and so I shouldn't be required to install node just to build my ReScript projects.

Removing the dependency on node would unlock:

  • Deno support via Deno.run
  • Bun support via bun run rescript

tom-sherman avatar Jul 09 '22 13:07 tom-sherman

I think moving the compiler frontend (the /rescript script) into a native binary is the way. Combine this with tiny scripts for node, bun, and deno to perform platform switching. So you end up with something like the following structure:

├── linux
│   └── rescript.exe
├── macos
│   └── rescript.exe
├── win32
│   └── rescript.exe
├── rescript
├── rescript.bun.js
├── rescript.deno.js
└── rescript.node.js

rescript.exe now contains all code to run the compiler, websockets and all.

The original rescript script can be the one that npm references, it can look at process.argv to check if we're running with npm/bun and choose the appropriate file.

This solution seems relatively scalable to new JS runtimes coming along, and gives you a full standalone binary to build ReScript projects on systems that don't have any JS runtime.

tom-sherman avatar Jul 09 '22 14:07 tom-sherman

I consider the same. The main rescript project can only provides binary releases of bsb bsc and bsfmt to package releases. The community provides command line release script or binary of node deno and bun more rust and more for their respective environments.

footearth avatar Jul 11 '22 05:07 footearth