mndeveci
mndeveci
DDeno
Created by mndeveci on 12/4/2023 in #help
Bundling a CLI written in JS with Deno
Hi team, Thanks for writing this excellent blog-post (and video) about rolling your own JS runtime with your application using deno_core crate. I am trying to wrap a CLI tool with that approach, however I am hitting different walls when I try to get things working. First of all, I can run this CLI by using Deno runtime directly. I can run deno run npm:{package-name} and it just works. However when I try to use your approach from the blogpost, I am hitting different walls; - If I provide npm:{package-name} in my JS file directly, it says it can't resolve the npm: links (I suppose I need to add more resolvers, but I couldn't find one from the crate documentation.) - If I install all dependencies in a local folder directly, and if I try to run this again, I am getting errors when a particular JS file tries to reference others from node_modules folder (Error: Relative import path "..." not prefixed with / or ./ or ../ from) - If I use esbuild to bundle everything into single JS file, it passes all of the first issues, however I am now hitting problems with core modules like fs or url since esbuild imports them with require("url"), which I believe not compatible with Deno. If I update those imports with the ones that you provided with following import statement import * as uri from "https://deno.land/std@0.173.0/node/url.ts"; I am getting following error: Error: Provided module specifier "https://deno.land/std@0.173.0/node/url.ts" is not a file URL. Can you help me what will be the best approach here and how can I resolve my problems above? Appreciate for your responses 🙏
3 replies