How can one patch a Deno dependency?
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?6 Replies
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:
can also target individual modules, eg:
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 thisGitHub
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.
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...
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"
Also have a look at the command
deno vendor
. It downloads all deps into a folderThanks! 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. 😁