What is the difference between these two imports? And which one should I use?

1. import { mongoose } from "https://deno.land/x/mongoose/mod.ts"; 2. import mongoose from "npm:mongoose@^6.7";
9 Replies
foobar
foobar3w ago
use 2nd choice first was designed before npm ecossytem could be used in deno natively
Doctor 🤖
Doctor 🤖3w ago
The first one is importing a specific function called mongoose. The second is importing the default export and calling it mongoose.
Manik Islam Mahi
Manik Islam MahiOP3w ago
That means the second option is updated and it is recommended by Deno, right? My confusion is "https://deno.land/x/mongoose/mod.ts"; and with "npm:mongoose@^6.7"
GREEN
GREEN3w ago
2nd. Deno made their own package registry named jsr and moved their standard libraries to jsr, so I think use registry is better that url import
Manik Islam Mahi
Manik Islam MahiOP3w ago
Thank you very much. But in jsr I can't find mongoose.
No description
Doctor 🤖
Doctor 🤖3w ago
Sorry. I only noticed the { mongoose } and mongoose, not a different from string. With the compatibility layer, it is recommended to use npm: over deno.land/x imports as version dependency deduplication is possible. Not all packages published on deno.land/x has been moved to JSR. My recommendation would be to look for dependencies on JSR and if it isn't there then use NPM.
GREEN
GREEN3w ago
jsr is just a better npm, don't let that bother you
Doctor 🤖
Doctor 🤖3w ago
If a package you use a lot is on npm and not jsr, you should encourage them to also publish in jsr.
Manik Islam Mahi
Manik Islam MahiOP3w ago
Thanks everyone. Hopefully Mongoose will be included in Jsr one day. ❤️