So Deno also has a standard library. So these are going to be JavaScript and TypeScript modules that are built and maintained by the core team. So they're audited and guaranteed to not be stale, not be malware, be maintained, and just generally audited to make sure that they work well with Deno.
I would say that these are on the Node.js side similar to Node's core modules such as FS, HTTP, et cetera. The only difference is that these live outside of the core repository, so they can be versioned independently, released independently, although currently they are released when the core runtime is released as well.
There's a lot of different modules there, things like FS, HTTP streams, things you'd be used to having in Node, UUIDs, WASI, a whole bunch of other stuff. There's not really a package manager for Deno, but these modules are hosted on the internet, so if you go to this deno.land.std, you'll get the latest version of the standard library, and then you can also version these, which is recommended as shown in the example at the bottom here. So if I wanted to import the copy function from the FS library, this is an example of I would do that while also ensuring that I'm getting version 0.141.0, so if there is a breaking change or anything else as the library evolves, you're guaranteed to get a version that you know works with your code.
And so talking about general dependency management, it works a lot like a browser. So there is no NPM. We only support ESM, there's no support for CommonJS. There are CDNs like ESM.sh where you can upload CommonJS modules and they will be transpiled for you, so that you can import them from there. You're not going to have a package.json file, there's not going to be a node modules, there index.js file. So when you do a require, you have to actually specify the file name and not the kind of magical index behavior.
So if you ever use something like Rust, I feel like Deno is kind of similar in the fact that it, when you run your code, it will actually fetch the code. It'll cache it locally so that you don't have to keep installing it. You can even do some work from an airplane if you need to. And it will compile those things automatically for you. So, you know, especially if you're downloading TypeScript, it has to be transpiled and whatnot. But Deno does all of these things for you kind of behind the scenes. And then for production apps, we recommend that you use a command called deno-vendor, which will basically download all of your dependencies locally. And then you can add them to source control or manage them however you want rather than trying to install things at deploy time in production. And as I said, there's no NPM, but there is package hosting at a site called deno.land slash x. So here I'm still showing the example from the previous slide. But if you replace that std at portion of the URL with x, then you would be kind of using, I guess, the Deno equivalent of NPM. And there's a web interface as well. So you can browse there and see all of the different third-party modules that people have created and uploaded. So there is a release schedule. Patch releases come out every week. Semver minor releases come out monthly.
Comments