Deno LandDeno

Deno 1.5 Release Notes

October 27th, 2020
Bartek IwaƄczuk, Luca Casonato, Ryan Dahl

Today we are releasing Deno 1.5.0. This release contains a few new features, many feature stabilizations, and a ton of bug fixes. Here are some highlights:

If you already have Deno installed you can upgrade to 1.5 by running deno upgrade. If you are installing Deno for the first time, you can use one of the methods listed below:

# Using Shell (macOS and Linux):
curl -fsSL https://deno.land/x/install/install.sh | sh

# Using PowerShell (Windows):
iwr https://deno.land/x/install/install.ps1 -useb | iex

# Using Homebrew (macOS):
brew install deno

# Using Scoop (Windows):
scoop install deno

# Using Chocolatey (Windows):
choco install deno

New features and changes

Improved bundling

Since the last release we have been hard at work to refactor our entire TypeScript compiler infrastructure. Because of this we were able to replace our aging bundling infrastructure with a new bundler based on swc.

This has led to a 3x performance improvement when we type-check your code, and up to a 15x improvement if you use the --no-check flag.

In addition to the performance improvements the bundler is now capable of tree shaking your code. This means it will remove code from the bundle that you are not actually using. This leads to a major size reductions in bundles. For example a bundle of the file_server example is 35% smaller in 1.5 when comparing to 1.4.

Bundles are now also emitted as a standard ES module, which means that dynamic import will work correctly now, and import.meta.url is also set correctly. If you were using Deno to bundle code for the browser, make sure to load the bundle as an ES module now (type="module" attribute on your <script> tag).

alert, confirm, and prompt added

This release adds the web platform APIs alert, confirm, and prompt. These have the same functions as they do in the browser:

Here is a little demo of these functions in action. You can try it out by running deno run https://deno.com/v1.5/alert_confirm_prompt.js.

let name = "";

while (true) {
  name = prompt("What is your name?");

  if (confirm(`Are you sure ${name} is your name?`)) {
    break;
  }
}

alert(`Hello ${name}!`);

Improvements to the REPL

The REPL has had a major refactor enabling several new features. Here are some of the highlights:

Stricter type checks in stable

This release enables the isolatedModules TypeScript compiler option for all users by default. In the 1.4 release this flag was enabled for users using --unstable. This option enables some stricter checks in the TypeScript compiler that will likely lead to some new errors you have not seen before:

ERROR TS1205: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.

These errors occur when interfaces or type aliases are re-exported. To fix the error, change your re-exports to use export type. Example:

// Bad
export { MyType } from "./mod.ts";

// Good
export type { MyType } from "./mod.ts";

For now you can override this option in a tsconfig.json.

Deno API additions and stabilizations

We have stabilized Deno.fsync(), Deno.fdatasync(), and their synchronous counterparts. These low-level methods are for ensuring modified file data is written to the disk drive.

There are also two new unstable APIs introduced to --unstable:

deno lint updates

deno lint has gotten some new rules this release. The main one is camelcase: it checks that all of your variable declarations use camelCase formatting. We are hoping to stabilize deno lint for Deno 1.6.

In addition to the new rules, we have introduced hints for lint diagnostics. These hints will suggest how the lint errors can be fixed.

Finally deno lint has a website now that you can use to view documentation and explanations for the rules. You can find it at https://lint.deno.land.

deno fmt --ignore now stable

The deno fmt --ignore flag is now available without the --unstable flag. This flag can be used to ignore some files or folders from being formatted or checked by the formatter.

Changes to std

The assertStringContains and assertArrayContains methods in std/testing/asserts.ts have been renamed to assertStringIncludes and assertArrayIncludes respectively, to match the the naming of the includes method on strings and arrays. To update your code, simply rename the imported methods:

- import { assertStringContains, assertArrayContains } from "https://deno.land/[email protected]/testing/asserts.ts";
-
- assertStringContains("denosaur", "deno")
- assertArrayContains(["deno", "new", "release"], "new")
+ import { assertStringIncludes, assertArrayIncludes } from "https://deno.land/[email protected]/testing/asserts.ts";
+
+ assertStringIncludes("denosaur", "deno")
+ assertArrayIncludes(["deno", "new", "release"], "new")

In addition to this renaming, a assertExists and assertObjectMatch assertion have been added to std/testing/asserts.ts:


The full release notes, including bug fixes, can be found at https://github.com/denoland/deno/releases/tag/v1.5.0.

HN Comments