rescript-compiler
rescript-compiler copied to clipboard
Support running `rescript` in non-node environments
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
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.
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.