Runtime bindings #2881
Replies: 4 comments 6 replies
-
This idea is not new, but widely inspired from what
|
Beta Was this translation helpful? Give feedback.
-
The "child_process" part of the proposal overlaps a bit with the idea of having a persistent "daemon" process shared between runs of the CLI and possibly the LSP frontend for editors. In this model the Now I don't think we would want to commit to making the WASM is a slightly different story because it can be used as a build target for the Rust code of the workspace server, letting it be run in "hosted mode" directly in the client process. Since the |
Beta Was this translation helpful? Give feedback.
-
If you are looking for node binding, https://github.com/napi-rs/napi-rs should be a good option, which is widely used in swc, parcel |
Beta Was this translation helpful? Give feedback.
-
I like the idea. What are your thoughts around using wasm for the |
Beta Was this translation helpful? Give feedback.
-
At the moment we are able to use
rome
only via CLI, which is fine for now, but it slows down adoption, because we can't use it in a runtime environment.My proposal here is start creating official binding for the most famous runtimes:
wasm
,node
anddeno
.The idea is to create some APIs to use the tools we have. Here's an example with Node.js runtime:
Under the hood the format function will communicate with our CLI via
child_process
, usingstdin
andstdout
, and by defining a protocol of communication between the processes:The
--runtime
is just a way to tell the CLI that a runtime is calling it, so it should do something different with the output and the errors.We decode the
stdout
and return the result. Of course this is a tiny example to give an idea.The core of the bindings will orbit around these concepts:
rust
we can useserde
, for the runtime we will have to do things ad hoc)stdin
,stdout
andstderr
as channelsThis would pave the foundation for the integration for any kind of runtime. For example, a Ruby on Rails application can create their own protocol decoder and runtime, so they can use Rome to format/lint their CSS/JSON files.
Beta Was this translation helpful? Give feedback.
All reactions