Jsr, esm, x and external ref
Hi,
I want to migrate most of my import to jsr to simplify code.
I use Hono and 3rd party middleware on Deno. I import them with esm / deno.land
Is there a better way to link dependencies with hono (or library with dependencies) ?
My actual settings
5 Replies
The documentation indicates that Deno has introduced the JavaScript Registry (JSR), which is a TypeScript-first, ESM-only module registry designed for the entire JavaScript ecosystem. JSR modules can be used from Deno and npm-based projects, and it's free and open source. This suggests that migrating your imports to JSR could indeed simplify your code by providing a more unified and streamlined way to manage dependencies.
For your current settings, you're already using JSR for importing
hono
, which is great. However, for other dependencies like hono/swagger-ui
, hono/zod-validator
, and hono/zod-openapi
, you're using esm.sh
with query parameters to handle external dependencies and target environments.
To further simplify your imports and potentially improve compatibility and performance, you could look for these packages on JSR and use them directly if they are available. This would allow you to take full advantage of JSR's benefits and possibly reduce the complexity of your import URLs.
Here's an example of what your imports
might look like if you were able to find all your dependencies on JSR:
Please note that the above example assumes that the packages are available on JSR, which you would need to verify. If they are not available, you may continue using esm.sh
or deno.land
as you currently are.
Remember to check the JSR or the respective package documentation for thecorrect version numbers and paths when migrating your imports. 🦕
This example lacks the versions.
I have the error message that
zod-openapi
is looking for export '@hono/hono@4.4.8'
. How to link them with npm ?Sounds like it might be a bug as you shouldn't need to import a dependency's dependencies.
Maybe want to open an issue on GitHub