Deno 2.0 is in the starting blocks: Release Candidate published

The release candidate for Deno 2.0 should contain everything that the final release will offer. This includes API updates and the new process variable.

Save to Pocket listen Print view
AI image: Dinosaur in front of screen with code

(Image: Erstellt mit KI durch iX)

4 min. read
Contents

The development team behind the JavaScript and TypeScript runtime Deno has published the release candidate for version 2.0. The biggest update since version 1.0 will bring important new functions to the Node.js alternative, such as the introduction of the global Node.js variable process. All expected features of the final version are already included in the current release candidate.

The global variable window has been on board since Deno 1.0 and was intended to make Deno as browser-compatible as possible. However, this variable posed some difficulties for users, so the Deno team decided to fall back on the alternative use of globalThis or self since version 1.40. window will now be dropped in version 2.0:

// Deno v1.x
window.addEventListener("load", () => {
  console.log("loaded");
});

// Deno v2.x
globalThis.addEventListener("load", () => {
  console.log("loaded");
});

The difficulty with the global availability of window was that many libraries check to see if they are running in the browser by looking for a window variable instead of a DOM – which led to a number of bugs in libraries that would have otherwise worked in Deno.

The new global variable process is available in the release candidate, which according to the development team was frequently requested by users. Previously, it was possible to use process by importing the node:process module, but many popular frameworks were dependent on the global availability of the variable. By adding process, significantly more code that was originally written for Node.js should now also run in Deno without any changes.

However, the Deno team still recommends preferring explicit imports. It has therefore added a new lint rule no-process-global, which will provide corresponding hints and quick fixes in the editor.

Deno 2.0 comes with some new functions for managing dependencies. Among other things, the deno add subcommand now handles specifiers with a subpath, as the Deno team demonstrates in comparison with the current version 1.46:

# Zuvor in Deno v1.46
deno add jsr:@std/testing/snapshot
error: Failed to parse package required: @std/testing/snapshot

Caused by:
    0: Invalid package requirement '@std/testing/snapshot'. Invalid version requirement. Invalid specifier version requirement. Unexpected character '/'
    ...

# Deno v2.0
deno add jsr:@std/testing/snapshot
Add jsr:@std/testing@1.0.2

# Deno v1.46
deno add npm:preact/hooks
error: Failed to parse package required: npm:preact/hooks

Caused by:
    0: Invalid package requirement 'preact/hooks'. Packages in the format <scope>/<name> must start with an '@' symbol.
    1: Packages in the format <scope>/<name> must start with an '@' symbol.

# Deno v2.0
deno add npm:preact/hooks
Add npm:preact@10.24.0

When adding dependencies, jsr: or npm: prefixes are now required to prevent potential ambiguity between packages with the same names in both registries.

Three APIs are now considered stable and therefore no longer require a --unstable flag: WebGPU, Deno.dlopen() and Deno.createHttpClient(). In addition, the development team has also revised the error messages to provide helpful hints when trying to use an unstable API without the corresponding flag.

One of the downward incompatible changes is the removal of numerous APIs. These include Deno.Buffer, Deno.close() and Deno.copy(). Five APIs are considered "soft-deprecated", which will continue to function but will receive neither updates nor bug fixes. The Deno team therefore recommends migrating to their stable equivalents:

  • Deno.serveHttp() – use Deno.serve() instead
  • Deno.run() – use the new Deno.Command() instead
  • Deno.isatty(Deno.stdin.rid) – use Deno.stdin.isTerminal() instead
  • Deno.isatty(Deno.stdout.rid) – use Deno.stdout.isTerminal() instead
  • Deno.isatty(Deno.stderr.rid) – use Deno.stderr.isTerminal() instead

The release candidate is intended to help uncover possible difficulties before the major release, Deno 2.0 appears. The Deno team is therefore actively looking for feedback from developers, either by creating an issue on GitHub or by contacting us in the #deno-2-help Discord channel.

All further details on the release candidate can be found on the Deno blog.

(mai)

Don't miss any news – follow us on Facebook, LinkedIn or Mastodon.

This article was originally published in German. It was translated with technical assistance and editorially reviewed before publication.