D
Deno

help

How can one patch a Deno dependency?

Bbombillazo9/7/2023
Hello, We're used to working with node and using patch-package to override and fix packages fairly easily. However, we're now using Deno due to using Supabase edge functions and have not figure a way to get the same dev experience. Is there any guide or way one can patch a dependency in Deno?
MGMark G9/7/2023
You can use import maps to map pretty much any module URL, lets say for example you want to use 0.200.0 of std lib everywhere, but some libs are using an older version, say 0.192.0, you can add this into your import map:
"imports": {
"https://deno.land/std@0.192.0/": "https://deno.land/std@0.200.0/"
}
"imports": {
"https://deno.land/std@0.192.0/": "https://deno.land/std@0.200.0/"
}
can also target individual modules, eg:
"imports": {
"https://deno.land/std@0.161.0/encoding/base64.ts": "https://deno.land/std@0.200.0/encoding/base64.ts"
}
"imports": {
"https://deno.land/std@0.161.0/encoding/base64.ts": "https://deno.land/std@0.200.0/encoding/base64.ts"
}
MGMark G9/7/2023
you can also use "scopes" in the import map to limit the scope of the mapping too... https://github.com/WICG/import-maps#scoping-examples ... although I've never needed to resort to this
GitHub
GitHub - WICG/import-maps: How to control the behavior of JavaScrip...
How to control the behavior of JavaScript imports. Contribute to WICG/import-maps development by creating an account on GitHub.
MGMark G9/7/2023
oh, you mentioned patching though, in which case if you want to override a library module with a local one you can do that too...
"https://blahblah/foo/iffy-module.ts": "./patched/iffy-module.ts"
"https://blahblah/foo/iffy-module.ts": "./patched/iffy-module.ts"
Bbombillazo9/7/2023
Hey, thanks for the info! So if I use an import_map.json and set a imports key to another version, all depedencies and sub dependencis that use the original verison will now point to the new one? Ok I guess I can answer my own question: yes hence the need/use of "scopes"
LLeokuma9/8/2023
Also have a look at the command deno vendor. It downloads all deps into a folder
Bbombillazo9/8/2023
Thanks! I ended up using deno vendor to pull the deps into a folder then using that to create our patched version and import it locally. 😁

Looking for more? Join the community!

Recommended Posts
Error running program that uses `fp-ts` from npm (`Is a directory (os error 21)`)https://github.com/Industrial/test-fp-ls/blob/main/mod.ts When I run `deno run -A mod.ts` I get: `Can't "Sign in" to deno deployHi There, I can't sign in to deno deploy. The first time I try it works, and it sets up the GitHub ADoes Deno NPM support other registries like github npm registry?Does Deno NPM support other registeries like github and if so, does it support private registeries?Piping streams through a shell program (ffmpeg) and writing the output to a fileI've been trying to use `ffmpeg` on the backend of my super simple audio-uploading app. I can save tUsing Deno to run JavaScript from GolangI just started looking into this, but I'm looking for something like rogchap.com/v8go but it would bRust compile deno_runtime errorHi <:ferrisUpsideDown:920769146399100958> I've been this error when I'm compiling my code that uselsp bug?Is there any reason why intellisense would identify the type correctly, but after completion it woulConvert m3u8 stream to mp4?Hey. Whats the best /fastest way to convert a m3u8 stream (all files are in a local folder) to a norGetting error trying to download NPM package``` Download https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.6.0.tgz D`deno check` error: Cannot find name 'Deno'`In my project, `deno check` has started producing the error `TS2304 [ERROR]: Cannot find name 'Deno'Read CSV files inside zip file using the web streams APII need to read a number of csv files inside a zip file. The basic example I've got working so far isUnable to find local file with installed deno moduleI am working on porting the 'octoherd/cli' to Deno. One of the things it does is load a script modulImporting NPM packages with `npm:` where package has `@` in the nameI want to import the package `@hono/zod-openapi`, version `0.30` I tried to add to my `deno.json` lHow to use KV Connect?Hello there <:HelloThere:730465880991072285> Is there any plan an making an STD module for creatindlopen() from web urlHey, is it possible to provide a url to the dll file from a cdn server? For example if I want to dDoes calling `bundle` inside a handler make sense?hey all I wanted to understand if this is smart to do. I am using the `cacheRoot` option and wanted Is WASM generally faster than using Deno FFI?...Deno hanging when trying to connect with MongooseWhen I try to connect to MongoDB using Mongoose the whole process just hangs until eventually timing