Modules and Third-Party Dependencies

Deno as a browser

Deno uses ECMAScript modules and imports that are fully compatible with the browser. The path to a module is absolute, so it includes the file extension, which is also standard in the browser world.

Deno takes the approach of being a browser for scripts quite seriously. One of the things it has in common with web browsers is that it deeply leverages URLs. They’re one of the most flexible ways to share a resource and work beautifully on the web. Why not use them for module resolution? That’s what browsers did.

Third-party entities

The fact that the path for modules is absolute makes it possible not to depend on third-party entities, such as npm or complex module resolution strategies. With absolute imports, we can import code directly from GitHub, from a proprietary server, or even from a gist. The only requirement is that it has a URL.

This decision enables a completely decentralized module distribution to be used, making module resolution inside Deno simple and browser compatible. This is something that doesn’t happen on Node.

Deno even leverages URLs for versioning. For instance, to import version 0.83.0 of the HTTP server from the standard library, we would use the following code:

Get hands-on with 1400+ tech skills courses.