rescript-lang / rescript-compiler

The compiler for ReScript.
https://rescript-lang.org
Other
6.75k stars 449 forks source link

Support running `rescript` in non-node environments #5530

Closed tom-sherman closed 4 weeks ago

tom-sherman commented 2 years ago

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:

tom-sherman commented 2 years ago

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.

footearth commented 2 years ago

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.

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.