deno_runtime NpmResolver like the CLI?

As far as I can tell, if I want to embed Deno in my Rust application using deno_core and deno_runtime, I would effectively need to implement my own npm: specifier resolution. https://docs.rs/deno_node/0.76.0/deno_node/trait.NpmResolver.html I found this trait I can implement, but what I really want is for module imports to just be identical to how they are when running code from the plain Deno CLI. People seem to say frequently that deno_runtime is the solution for copying the Deno CLI's behavior in a custom executable, but I can't find any existing structures that mimic the module-graph mapping behavior that is included with the CLI, so wouldn't I be better off just forking the CLI code?
NpmResolver in deno_node - Rust
API documentation for the Rust NpmResolver trait in crate deno_node.
OD
Optical Disc 💿56d ago
No description
OD
Optical Disc 💿56d ago
it looks like the trait is only implemented in the cli/ directory in the deno repository and even if I just do the work and implement my own npm resolver, surely there's other things that I'd later find only exist in cli/ and not runtime/ and surely, if I just add a lib.rs file and make a minimal edit to the Cargo.toml, it'll be easy to keep up with new versions of Deno
DAH
Deno AI Helper56d ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the information you've provided in your message, it seems like you are looking to replicate the module resolution behavior of the Deno CLI within a Rust application using deno_core and deno_runtime. The NpmResolver trait you found is indeed meant to be implemented if you want to resolve npm specifiers. If you're looking for a way to handle module imports exactly as the Deno CLI does, without implementing your own resolver, it's true that deno_runtime should provide the necessary functionality, as it aims to offer a high-level runtime environment similar to the Deno CLI. However, if you can't find an existing structure within deno_runtime that mimics the module-graph mapping behavior of the CLI, forking the CLI code might be a solution, but it's not an ideal one since it could lead to maintenance overhead and divergence from the upstream Deno project. Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of this advice. It might be beneficial to look into the source code of Deno itself or to reach out to the Deno community for more insights on how to achieve the behavior you desire without forking the CLI code.
OD
Optical Disc 💿56d ago
I couldn't find a github issue about this either
More Posts
Is it possible to share the same privateLink in Deno Subhosting?Recently we are trying to implement a "custom js function" module in Deno Subhosting, our concern isSource generation for dependenciesHello, I'm working on a source gen for a library (Node, Deno, Bun) and currently my idea was to overFetch errors outFailed to serve connection: hyper::Error(BodyWrite, Os { code: 55, kind: Uncategorized, message: "NoDeno Jupyter Notebook - monorepo supportHi all! We have a typescript-based monorepo that uses Turbo/Pnpm/etc Our primary reason for coming workspace importI have a vsc root-level settings.json file ```json { "deno.enable": true, "deno.enablePathsHow Enable HTTPS localhost DENO?I want to run Deno Oak over Https in local. I use OpenSsl/mkcert to create cert and key. But no workDeny env permissions silently (without throwing)Hi. An `npm` module I'm using tries to read, or rather check for an existence of an `env` variable.HTTPS Oak DenoI want to run Deno Oak over Https in local. I use OpenSsl to create cert and key. But no works.WebSocket proxy Deno.createHttpClientIs it possible to use proxy for web socket connections in Deno?How to feed a ReadableStream / async Generator into a Response object?``` Bun.serve({ async fetch(req) { return new Response( async function* stredeno_core manual tick/poll(Learning the ropes of deno_core) Two related questions: - If I create a JsRuntime, and call `polIs there any way to know currently running has been deno compiled?Can something like Deno.compiled be used to determine this?Testing API serverI'm trying to setup an API server using deno and am trying to figure out what the canonical way of tDebugging high (string) heap usageI was observing relatively high memory usage in my deno applications (web-applications). I haven't a