I have a JSR Package: Can I Import it From My Filesystem Instead of jsr.io?
Hello! 👋 I have a JSR package, but I'm doing some local development and I have an app that imports my SDK JSR package, and the SDK imports more library packages in a Deno workspace.
I need to be able to test my local changes without having to publish a new version of the JSR package each time, but I'm not sure how to do that.
I tried to use "patch", but one of my JSR libs also depends on an NPM package, and it seems that the NPM package is not properly loaded.
Specifically, I have a workspace with some libraries on GitHub: muni-town/leaf, and I have an SDK that uses a library in that workspace muni-town/roomy-sdk. I can't figure out how to open the Roomy SDK repo, and have it use my local version of Leaf so that the package appears to type correctly in VSCode.
8 Replies
I've tried just switching my imports map in the Roomy SDK to specify the
index.ts
of the package it's trying to import, the issue is that index.ts
imports loro-crdt
which is in its import map, and the import maps are not merged.
I.e. there's no way for me to add another package on my local filesystem as a dependency by specifying, for example, it's jsr.json
file or deno.json
file, so that it properly handles the module exports, and import maps.I can't speak for the typings in your IDE, but the actual running should be done via the "patch" property
deno.json of package to import:deno.json of package being ran:The versions must match or it won't patch it
I wish Deno can resolve "path" dependencies in a similar way as Cargo does (or Elixir's Mix).
Without dealing with patches, just specify path to a Deno project and it will do the magic for you.
If you are using workspaces it works without any configurations
Yeah, the workspace worked really nice for the repo with a bunch of libraries in it, but it doesn't work when I have code in two different Git repos.
Trying that it tells me that it requires an unstable
npm-patch
flag because the lib I'm patching depends on an NPM package, and then if I add that flag and try to run the project it says:
It appears that it's not installing the npm package that is depended on by the library I'm patching.
Ahhh, just figured it out, I need to also set the nodeModulesDir
setting to "auto"
.
Finally it works!
Thanks folks!@i_use_arch_btw that's exactly what the
patch
feature in deno.json
does. It works the same way as path
in Cargo. We just picked a different name that is more familiar to JS devsWow, this is amazing then!
The last I looked, which was a while ago, there isn't a lot of documentation on the patch property.