The State of Node Compatibility in Deno

Rate this content
Bookmark

Deno is a next-generation TypeScript and JavaScript runtime from the original creator of Node.js. Deno is fast, secure by default, and provides a great developer experience, with TypeScript, JSX, testing, linting, and more all included out of the box. And best of all - you can bring many of your favorite to Node modules with you to Deno. In this talk, we'll cover the current state of backward compatibility with Node.js projects and modules in Deno. We'll demonstrate what works with zero configuration, and the available mechanisms in Deno that will let you bring the best of the Node ecosystem along for the ride.

This talk has been presented at Node Congress 2024, check out the latest edition of this JavaScript Conference.

FAQ

The "deno.json" file is used to configure Deno projects, enabling features like TypeScript type checking and node compatibility options.

Sloppy imports allow Deno to handle file imports without explicit file extensions, similar to how Node.js handles module imports.

One major feature of Deno compared to Node.js is its native support for TypeScript and built-in tooling without requiring third-party dependencies.

Deno requires explicit permission from the developer for sensitive APIs like network access, file system access, and system environment access.

Deno provides built-in tools such as a test framework, linter, formatter, and a compile feature to create portable executable files.

Deno can run existing Node.js projects by making minor changes such as converting CommonJS modules to ES modules and using Deno’s node compatibility features.

The "bring your own Node modules" (BYONM) feature allows developers to use their own package manager to manage dependencies in Deno projects.

More information on Deno's node compatibility features can be found in the official Deno documentation at docs.deno.com.

Kevin Wendray and David Sherritt are the members of the Deno team mentioned in the presentation.

Deno is a next-generation JavaScript runtime with native support for TypeScript and numerous built-in tools designed to improve server-side JavaScript development.

David Sherret
David Sherret
Kevin Whinnery
Kevin Whinnery
23 min
04 Apr, 2024

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Today's Talk introduces Deno, a next-generation JavaScript runtime with native TypeScript support and improved server-side development features. Deno offers granular permissions for sensitive APIs and includes built-in tools like a test framework and linter. The Talk demonstrates how to use Deno with an existing Node.js project, showcasing compatibility and import features. It also discusses upcoming features like bringing Node modules to Deno and handling file extensions. Overall, Deno provides a seamless transition for Node developers and offers a range of powerful tools and features.

1. Introduction to Deno and Node Compatibility

Short description:

Today, we are here to talk to you about the state of node compatibility in Deno. Deno is a next-generation JavaScript runtime with native support for TypeScript and a number of features that improve server-side JavaScript development. We'll give you a quick demo of Deno and then focus on node compatibility features. We'll show you how to apply these features in an existing node project. Let's get started with a Deno demo, where you'll see the native support for TypeScript and how to set up a Deno server.

What's up, everybody? My name is Kevin Wendray. I'm part of the Deno team. And I'm joined by David Sherritt, who is also part of the Deno team, working on the Deno runtime. And today, we are here to talk to you a little bit about the state of node compatibility in Deno.

So for those of you who haven't heard of Deno before, it's a next-generation JavaScript runtime with native support for TypeScript, lots of nice built-in tooling that we'll get into here in a second, and a number of features that we think kind of improve the state of server-side JavaScript development. But a major thing that you might not know about Deno is how much work has gone into backwards compatibility with Node.js as a kind of a key component of server-side JavaScript development. So in this presentation, we're going to give you just a quick demo of Deno to give you a sense of kind of how it works, how it might differ from Node.js. And then we're actually going to spend the majority of our time digging into some node compatibility features to let you know how those work, how you might apply those in the context of an existing node project.

So we're actually going to be taking a simple Node.js project that uses Express and making some changes to it using some of the node compatibility features that exist in Deno. So let's go ahead and get started. And my friend David, by the way, will be joining us kind of as our color commentator. David's actually the implementer of many of these compatibility features we're going to talk about. So I'm going to ask him some questions, and he's going to be my pair programmer as we implement some of these things. So what do you think, David? You ready to do a quick Deno demo? Definitely. All right, let's do it. So I'm going to jump over to just a sort of a blank Visual Studio code project where I'll do a very quick Deno demo just to give you a sense of how the runtime works.

So one of the things that you'll notice in Deno right away is that there is native support for TypeScript. So without any dependencies to install or anything like that, you can very quickly start writing TypeScript code. And I'll implement sort of a hello world Deno server. And in Deno, that's going to be done using the Deno namespace. And there is a Deno serve command, which is going to allow us to set up a handler function that will take a web standard request object and allow us to handle incoming requests. If you had a Deno JSON, then you'll get the type checking. Yeah, exactly. That's definitely true. So I was going to point out you might notice some of the squiggles and the lack of completion. And the way that I can fix that, as David mentioned, is by adding a deno.json, which will kind of enable my VS Code plugin for Deno to start to give me some hints about Deno serve and the built in Deno namespace, things like that. So as the first argument to Deno serve, again, I'm going to pass in a request object. And in this case, I'm just going to return a new response, which is going to be hello world. And to make the TypeScript linter happy, I'll just add a leading underscore there to indicate that I'm not actually using this request object. So this is kind of, once again, without any third party dependencies, I can write some TypeScript that's going to serve HTTP requests.

2. Deno Runtime Features and Permissions

Short description:

Deno has a unique feature of granular permission to sensitive APIs like network access, file system access, and system environment access. You have to explicitly opt into these permissions as a developer. Deno also offers built-in TypeScript support, an excellent Visual Studio Code plugin, and runtime permissions.

And if I run this with Deno run, you'll notice that I'm actually challenged for permission. And that's another feature of the Deno runtime, which is unique to Deno and doesn't exist in Node in the same way, is granular permission to sensitive APIs like network access, access to the file system, access to the system environment. Those types of permissions you have to explicitly opt into as a developer. So in this case, I'm going to say yes, I'm happy to allow network access. And now I have a server listening on localhost 8000. So if I spin up a new Chrome browser, which I will here just momentarily, and go to localhost 8000, there is my hello world response. So that's just a really quick demo of a couple of things. So we have built-in TypeScript support. We have an excellent Visual Studio Code plugin, which gives you some IntelliSense and other hints in the editing environment. And we have some of these built-in runtime permissions.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Node.js Compatibility in Deno
Node Congress 2022Node Congress 2022
34 min
Node.js Compatibility in Deno
Deno aims to provide Node.js compatibility to make migration smoother and easier. While Deno can run apps and libraries offered for Node.js, not all are supported yet. There are trade-offs to consider, such as incompatible APIs and a less ideal developer experience. Deno is working on improving compatibility and the transition process. Efforts include porting Node.js modules, exploring a superset approach, and transparent package installation from npm.
Javascript Should Come With Batteries
React Day Berlin 2023React Day Berlin 2023
30 min
Javascript Should Come With Batteries
Watch video: Javascript Should Come With Batteries
JavaScript Should Come With Batteries: Deno is a next-generation JavaScript runtime that addresses the lack of built-in tooling in JavaScript. It provides a secure and simple way to develop applications with built-in testing, linting, formatting, and a language server for VS Code. Deno is compatible with Node.js and NPM, supports web standard APIs, and allows code portability between frontend and server. It also offers features like a built-in database, a key-value store, and transparent monetization with Deno Deploy.
Deno 2.0
Node Congress 2023Node Congress 2023
36 min
Deno 2.0
Top Content
The Talk discusses forced optimization with Node and Deno, with Deno aiming to pursue the same goals in a more expansive and modern way. Deno has built-in support for NPM and enforces security constraints. It also has a key-value database called Deno KV, which will be a core part of the Deno 2 API. Deno Deploy is a serverless Edge Functions platform powered by FoundationDB, optimized for fast reading and ideal for building eCommerce sites or application servers at the edge. Deno 2.0 is coming soon with more features under development.
Fresh: a new full stack web framework for Deno
Node Congress 2023Node Congress 2023
24 min
Fresh: a new full stack web framework for Deno
Today's Talk introduces Fresh, a full-stack web framework for Deno, and covers its features, such as static files, routes, and data-fetching. It also discusses middleware, error pages, and styling options. The Talk explains the Islands architecture used by Fresh to enable client interactivity. The demo showcases the use of hybrid routes and islands components, and resources for Fresh, Deno, Preact, TypeScript, and web standards are provided.
Bun, Deno, Node.js? Recreating a JavaScript runtime from Scratch - Understand magic behind Node.js
Node Congress 2023Node Congress 2023
29 min
Bun, Deno, Node.js? Recreating a JavaScript runtime from Scratch - Understand magic behind Node.js
The Talk explores the magic behind Node.js and delves into its components, including V8, libuv, and the C++ bridge. It discusses the workflow and execution process, the use of NodeMod, and the understanding of console functions. The Talk also covers Node.js functions and scheduling, the introduction of runtimes, and the collaboration between JavaScript runtimes. It concludes with insights on content production, the choice of Node.js, and the inspiration behind it.
Writing universal modules for Deno, Node, and the browser
TypeScript Congress 2022TypeScript Congress 2022
25 min
Writing universal modules for Deno, Node, and the browser
Deno is a modern runtime for TypeScript and JavaScript that runs out of the box and is secure by default. The Talk covers building a greeting message library with Deno, compiling Deno libraries for Node consumers, setting up the editor and writing code, writing tests and running them with dnotest, code formatting, linting, and publishing, publishing to NPM and running tests, and building and publishing the NPM package. The speaker emphasizes the ease of use and integration of Deno's tooling system.

Workshops on related topic

Building a Hyper Fast Web Server with Deno
JSNation Live 2021JSNation Live 2021
156 min
Building a Hyper Fast Web Server with Deno
WorkshopFree
Matt Landers
Will Johnston
2 authors
Deno 1.9 introduced a new web server API that takes advantage of Hyper, a fast and correct HTTP implementation for Rust. Using this API instead of the std/http implementation increases performance and provides support for HTTP2. In this workshop, learn how to create a web server utilizing Hyper under the hood and boost the performance for your web apps.
Writing Universal Modules for Deno, Node and the Browser
Node Congress 2022Node Congress 2022
57 min
Writing Universal Modules for Deno, Node and the Browser
Workshop
Luca Casonato
Luca Casonato
This workshop will walk you through writing a module in TypeScript that can be consumed users of Deno, Node and the browsers. I will explain how to set up formatting, linting and testing in Deno, and then how to publish your module to deno.land/x and npm. We’ll start out with a quick introduction to what Deno is.