Most complete Deno Rust runtime?
I’m trying to embed the Deno runtime into my Rust program. I’m looking for the most “complete” Deno runtime with TS transpilation, basic ops (fetch/console/fs/etc), imports, and most of the things a basic TS runtime would have.
So far I only found:
-
deno_core
and https://deno.com/blog/roll-your-own-javascript-runtime-pt2: too much boilerplate
- deno_runtime
: no TS support
- deno
: no public facing API
What would be my best option?5 Replies
Based on the documentation, the
deno_core
crate is the primary component for embedding a JavaScript runtime into your Rust application. It provides a JsRuntime
struct that encapsulates a V8 engine instance and allows integration with an event loop. However, as you mentioned, it might require more boilerplate code than you'd prefer.
The deno
crate, on the other hand, is the main repository that provides the deno
CLI and includes TypeScript support out of the box, as well as a variety of built-in development tooling. However, the documentation does not mention a public facing API for this crate.
Unfortunately, the documentation does not provide a clear answer to your question. It might be best to reach out to the Deno community or maintainers for more specific advice on this topic. 🦕I am looking to solve a very similar problem, did you happen to find a path forward?
deno_runtime
is probably the best bet -- you should be able to provide the TypescriptModuleLoader
from the ts_module_loader
example to give it near-full functionality. If we can expose more functionality from the CLI by moving into runtime, we can definitely look at that.I tried the
deno_runtime
approach, but it’s missing quite a bit. Getting [JT]SX? evaluation with local imports is pretty easy, but the hard part is getting feature parity with the Deno CLI: things like remote modules, npm support, HMR, etc is quite complex. Keeping up with upstream is pretty hard too.
My initial attempt is here: https://github.com/yklcs/AreumGitHub
GitHub - yklcs/Areum: An experimental static site generator
An experimental static site generator. Contribute to yklcs/Areum development by creating an account on GitHub.
Are there any plans to make the
deno
crate a library crate? Refactoring and exposing deno::tools::*
as a library doesn’t seem too hard at first glance since everything is structured pretty nicely.
One would need to fork the entire project to use parts of the Deno CLI currently as I understand