Deno 1.37: Modern JavaScript in Jupyter Notebooks

By admin

Deno
ORG

’s mission is to dramatically simplify software development. In

Deno 1.37
ORG

, we’re happy to extend this to interactive

Jupyter
PERSON

notebooks. Starting in

1.37
CARDINAL

, you can use the new deno jupyter command to create a

Deno
ORG

kernel that can be used within notebooks. Additionally,

Deno 1.37
ORG

comes with stronger Visual Studio Code and LSP support, better testing performance, improved

Node
ORG

compatibility, and many bug fixes.

If you already have

Deno
ORG

installed, upgrade to version

1.37
CARDINAL

in your terminal with:

deno upgrade

If you don’t yet have

Deno
ORG

installed, you can install it with

one
CARDINAL

of the following commands, or many other ways.


MacOS / Linux
ORG

Install

curl

-fsSL
PERSON

https://deno.land/x/install/install.sh | sh


Windows Install
PRODUCT

irm

https://deno.land/install.ps1 |
LOC

iex

Here’s an overview of what’s new in

Deno 1.37
ORG

.

Deno 1.37 at a glance 📒

Jupyter
PERSON

notebooks

Deno
ORG

now smoothly integrates with

Jupyter
PERSON

notebooks, bridging the gap between scripting and analysis.

Jupyter notebooks 🖥️ VSCode extension and language server The vscode extension continues to improve with better detection of `deno.json`, the introduction of `deno.disablePaths` configuration, better support of file renaming, npm specifier completions, a new configuration called `deno.suggest.completeFunctionCalls`, and many more fixes.

VSCode extension and language server 🧪 Testing improvements Simpler, faster, better! We’ve revamped our testing suite, making it more intuitive to write tests and ensuring quicker feedback loops.

Testing improvements


CARDINAL

Node.js compatibility improvements Continued improvements to built-in

Node
ORG

APIs means that

Deno
ORG

now supports modules like `npm:mssql`, `npm:mineflayer`, and `npm:web-push`. Most NPM modules work out of the box in

Deno
ORG

.

Node.js compatibility improvements

🏝
CARDINAL

️ Quality of life improvements Support for new import attributes syntax, graceful shutdown using `

Deno.serve
PERSON

()`, and numerous performance improvements.

Jupyter notebook integration

Deno v1.37 ships with a built-in support for

Jupyter
PERSON

notebook kernel, which brings modern

JavaScript
PRODUCT

and

TypeScript
ORG

and unlocks a whole new set of data science and machine learning possibilities.

If you haven’t already, start by installing

Jupyter
PERSON

– this command assumes

Python
PERSON

and pip are installed on your system.

pip install jupyterlab

If you have Python

3
CARDINAL

installed, you might need to use the pip3 command instead. Other install options are covered here.

To get started using

Deno
ORG

in Jupyter, run:

deno jupyter –unstable

and then follow the prompts to complete the installation. More documentation on deno jupyter –unstable can be found here.

You can now create interactive

REPL
ORG

sessions using either Jupyter Lab or your favorite IDE which supports these notebooks.

Using the

Deno
ORG

kernel in a Jupyter notebook

Using the

Deno
ORG

kernel in a CLI

You have access to all of

Deno
ORG

’s APIs, as well as npm modules right from your notebook.

Not only can you use modern

JavaScript
PRODUCT

in Jupyter notebooks, but you can also import

D3
ORG

from npm to visualize your data:

Screenshot contributed by

Elijah Meeks
PERSON

In addition, you can also provide rich output from your cells by returning an object that contains the Symbol.for("Jupyter.display") function:

You can even connect to your hosted

Deno KV
ORG

with

Deno KV Connect
ORG

and pull live data straight into a notebook:

Finally, if you’re using

Noteable.io
ORG

, you can use

Deno
ORG

in your hosted

Jupyter
PERSON

notebooks

today
DATE

.

Noteable.io
ORG

’s Chief

Architect
PERSON

and a core maintainer of the

Jupyter
PERSON

project,

Kyle Kelley
PERSON

, describes the possibilities unlocked from this integration:


Deno
ORG

’s new

Jupyter
PRODUCT

kernel unlocks tremendous potential for data science workflows by people who can write JavaScript. I’m thrilled by the possibilities enabled by native access to

Deno
ORG

’s modern

JavaScript
PRODUCT

runtime and built-in

TypeScript
ORG

support. JavaScript developers can create notebooks to analyze data, build models, and create interactive reports. Gone are

the days
DATE

of configuring

Babel
PRODUCT

and

TypeScript
ORG

with a

Jupyter JavaScript
PRODUCT

kernel. Since

Deno
ORG

supports

ESM
ORG

imports based on URLs, the

Deno
ORG

kernel makes it incredibly easy to share notebooks that run anywhere. Dependencies are declarative. Organizations can take advantage of existing Jupyter deployments and immediately get access to

Deno
ORG

’s secure runtime sandbox without giving up the flexible workflow Jupyter enables.

For more details on using

Deno
ORG

’s Jupyter integration, check out our docs. We’re looking for feedback from the community on this feature, so please try it out and let us know if you find any problems or missing features.

VSCode extension and language server

Enable via detection of deno.json

The

Deno
ORG

extension is disabled by default for the convenience of users working on non-Deno TypeScript projects. Previously, you must have specified "deno.enable": true in your editor’s workspace settings to enable it. Now, as long as your project root contains a deno.json file, you may leave it unspecified. You can still specify "deno.enable": false to override this.

To assist with cases like the above, a new "deno.disablePaths" setting has been introduced. This is a complement to the existing "deno.enablePaths" setting. If you have nested non-Deno sub-projects, it will disable the

Deno
ORG

extension for the specified paths.

{ "deno.disablePaths" : [ "

./node_api/
PERSON

" , "./vsc_extension/" ] }

This is a widely used refactor among many languages.

Deno
ORG

’s language server now offers this functionality – upon renaming a JS/TS file, you will be prompted to optionally update import specifiers discovered across your project which point to that file.

NPM specifier completions

When typing an npm: URL in an import specifier, you will now be shown autocomplete options for

NPM
ORG

packages. These are retrieved by searching the

NPM
ORG

registry.

import "npm:prea" ;

But potentially more useful: If you’ve typed

npm:<package_name>@
PERSON

, you’ll see autocomplete options for the latest published versions of that package. Looking up valid versions was a tedious part of using NPM specifiers. Now this is done for you.

import "npm:preact@" ;

Function call completions

Set "deno.suggest.completeFunctionCalls": true to include parentheses and argument placeholders when selecting an autocomplete option for a function whose signature is known. This is a re-implementation of "typescript.suggest.completeFunctionCalls" and "javascript.suggest.completeFunctionCalls" .

// Type the following: addEventLi // and select the autocomplete option for `addEventListener`. // `"deno.suggest.completeFunctionCalls": false`: addEventListener // `"deno.suggest.completeFunctionCalls": true`: addEventListener(type, listener)

A new "deno.cacheOnSave" setting has been introduced. When enabled, the extension will automatically cache new dependencies when you save a file. This is a huge convenience for users who are frequently adding new dependencies to their projects and removes the need to run “Cache dependencies” command from the command pallete. Currently this setting is off by default, but we plan to enable it by default in a future release.

Test explorer and code lens fixes

Many testing

API
ORG

bugs have been fixed since

1.36.0
CARDINAL

:

The test explorer no longer freezes when executing tests with steps.

Test steps are properly replaced in the explorer when their names are changed. Previously a new step would be registered for each character typed, and you had to reset the language server to clean it up.

In some cases, nested test steps with the same name would not be registered uniquely from one another and share the same entry in the explorer. The ID allocation is fixed now.

Running all tests via the test explorer no longer evaluates modules which don’t contain any tests.

Modules without tests are no longer shown in the test explorer.

Running a single test via code lens, while another test in the file has { only: true } , would previously not run any tests and log a failure because the only option was used. Now it behaves as expected and properly ignores other tests.

, would previously not run any tests and log a failure because the option was used. Now it behaves as expected and properly ignores other tests. Running a test named foo via the code lens no longer runs other tests in the same file whose names contain foo (eg.

foobar
TIME

). Thanks

@Leokuma
PERSON

!

via the code lens no longer runs other tests in the same file whose names contain (eg. ). Thanks

@Leokuma
PERSON

! The set of files that are included in the test explorer and show the Run test code lens are now filtered based on deno.json fields exclude , test.exclude and test.include .

Other fixes

Show source module in the label description for auto-import completion entries.

Relative and bare specifiers are prioritized over remote URLs for auto-import completion entries.

Formatting preferences are respected when inserting auto-import code.

JSON module specifiers which don’t end in .json no longer show an erroneous diagnostic about not having a default export. This affects data URLs and specifiers containing a query string or fragment.

no longer show an erroneous diagnostic about not having a default export. This affects data URLs and specifiers containing a query string or fragment.

Quickfix
PERSON

actions are sorted by

tsc
ORG

,

deno
ORG

, then deno-lint .

, , then . Import completions now include local JSON modules.


Match
PERSON

"deno.enablePaths" entries by whole path components. Previously file names that were string-prefixed by an entry would be enabled (eg. foo would enable both foo.ts and

foobar.ts
CARDINAL

). Now it must be path-prefixed, i.e. an entry must be the exact name of the file or

one
CARDINAL

of its parent directories.

entries by whole path components. Previously file names that were string-prefixed by an entry would be enabled (eg. would enable both and ). Now it must be path-prefixed, i.e. an entry must be the exact name of the file or

one
CARDINAL

of its parent directories. Always use –inspect-wait over –inspect-brk when debugging a test. There were still cases where the less suitable –inspect-brk was used. Thanks @jeiea!

over when debugging a test. There were still cases where the less suitable was used. Thanks @jeiea! Correct handling of language server clients which don’t support workspace/configuration requests. These requests were sent to clients incapable of handling them in some cases.

requests. These requests were sent to clients incapable of handling them in some cases. Remove dead "deno.testing.enable" setting. This didn’t do anything.

Testing improvements

Continuing improvements to

Deno
ORG

’s testing APIs from the last release, we have some exciting updates

this month
DATE

as well.

Speed improvements

We improved performance of running tests and

Deno
ORG

can now run

up to 14,000
CARDINAL

tests per

second
ORDINAL

. This was achieved by optimizing the sanitizers that

Deno
ORG

’s test runner has built-in, lowering baseline overhead from 3ms to less that

0.1ms
PRODUCT

per test case.

We have further plans to improve testing performance and you can expect more speed ups in the next release.

TAP test reporter

deno test can now output test results in

the Test Anything Protocol
LAW

. You can enable it by using –reporter=tap flag:

$ deno test –reporter = tap ./test.ts

TAP
ORG

version

14
CARDINAL

ok

1
CARDINAL

– test

0
CARDINAL

ok

2
CARDINAL

– test

1
CARDINAL

ok

3
CARDINAL

– test

2
CARDINAL

ok

4
CARDINAL

– test

3
CARDINAL

ok

5
CARDINAL

– test

4
CARDINAL

ok

6
CARDINAL

– test

5
CARDINAL

ok

7
CARDINAL

– test

6
CARDINAL

ok

8
CARDINAL

– test

7
CARDINAL

ok

9
CARDINAL

– test

8
CARDINAL

ok

10
CARDINAL

– test

9 1
CARDINAL

..

10
CARDINAL

Thank you to Valentin Anger for implementing this feature.

Shorthand methods for focusing and ignoring tests

You can now focus and ignore tests using shorthand methods Deno.test.only and

Deno.test.ignore
PERSON

, like so:


Deno
ORG

. test . only ( function myTest ( ) { } ) ;

Deno
ORG

. test . ignore ( function myTest ( ) { } ) ;

It’s a little change, but makes it easier and faster to iterate than having to specify an option bag like

Deno.test
ORG

({ only : true }, function myTest() … .

Quality of life improvements

Besides changes described above, we have plethora of other small changes that makes testing experience in

Deno
ORG

better:

Filtered suites are not displayed

If you use –filter <name> flag to run only a subset of tests, the test runner will now only show the filtered tests in the output. This makes it easier to focus on the tests you care about.

Before Deno v1.37:

In Deno v1.37:

ASCII escape characters no longer mangle test names

Characters like

, \t , etc are now properly escaped in test names, so you if you really need to include them in the test name, the reporter output won’t get broken.

–trace-ops shows more details

If you have leaking ops in your tests, –trace-ops flag can help you catch where the leak is coming from. With this release, this flag got smarter and can show useful information in more cases.

Filtering by name takes precedence over only option

If you have a test suite with the only option set to true , but you want to run some other test filtered by a name (using –filter <name> flag), the test will be properly run.

JUnit reporter includes more information

File, line and column attributes are properly added to the produced report.

Exclude internal code from coverage report

The coverage just got faster and less noisy, by excluding internal

Deno
ORG

code from the generated report.

If you have other ideas how to make

Deno
ORG

’s test runner better, please let us know by opening an issue in

Deno
ORG

’s bug tracker.

Node.js compatibility improvements

A bunch of very important fixes to Node.js APIs landed in this release:

child_process no longer throws if env var is undefined or null

no longer throws if env var is or crypto module implements

AES
ORG

GCM cipher

module implements

AES
ORG

GCM cipher http now correctly handles

Content-Length
ORG

header, emits "error" event, destroying request properly cleans up allocated resources

now correctly handles header, emits event, destroying request properly cleans up allocated resources

http2
PRODUCT

adds support for ClientHttp2Session and connect API

adds support for and API process.title no longer throws

no longer throws

repl._builtinLibs
ORG

is now supported

is now supported tls now implements

TLSSocket._start
EVENT

method

now implements method worker_threads.Worker now correctly handles process.argv

now correctly handles zlib supports dictionary option

supports option require now uses canonicalized paths for loading content

now uses canonicalized paths for loading content

Additonal
PERSON

npm modules tested and working:

mssql , mineflayer ,
ORG

infiscal , and web-push

If you want to know more about Node.js compatibility in

Deno
ORG

, check out our Node.js compatibility list.

Quality of life improvements

Vendor as cache override (unstable)

It is now possible to vendor dependencies by simply adding the following to your deno.json :

{ "vendor" : true }

The next time you run or cache (ex.

deno cache mod.ts
ORG

),

Deno
ORG

will populate a ./vendor folder with the remote https/http dependencies used by the program.

Alternatively,

vendoring
PERSON

is possible via the –vendor flag.

Note that

Deno
ORG

treats the ./vendor folder differently because it is not always possible to map urls directly to a file system.

You will probably find this feature much easier to use than the deno vendor subcommand as it takes very little overhead to manage and works in more scenarios. For that reason, it might make sense for the deno vendor subcommand to be removed from the

CLI
ORG

and distributed as a separate tool instead (for more details, see issue #

20584
MONEY

).

Import attributes

This release adds support for the Import Attributes proposal. The proposal was earlier know as “import assertions”, and

Deno
ORG

had support for it since version

1.17
CARDINAL

.

Import attributes allow you to import JSON files using import declarations:

import jsonData from "./data.json" with { type : "json" } ;

It also works with dynamic imports:

const jsonData = await import ( "./data.json" , { with : { type : "json" } } ) ;

The old syntax using assert is still supported, but deprecated. We are going to phase it out over the next few releases; in the next releases

Deno
ORG

will print a warning if you use the deprecated assert syntax in your own code.

This release brings a new, unstable API: Deno.Server.prototype.shutdown(): Promise<void> .

const server =

Deno
ORG

. serve ( ( _req ) => new Response ( "hello world!" ) ) ; setTimeout ( async ( ) => { await server . shutdown ( ) ; } ,

3000
CARDINAL

) ;

Before this release, it was only possible to close the server “abruptly”, by using the

AbortSignal
ORG

passed to the server during construction. However it’s not always desirable to close the server in such fashion, in most cases you want to wait for all the in-flight requests to finish before closing down the server.

This new

API
ORG

is unstable, because we want to gather feedback from the community before stabilizing it; additionally we want to add a timeout parameter, that will control how long the server waits for the pending requests to complete before closing them forcefully.

Performance improvements

This release we optimized numerous Web APIs as well HTTP related APIs (both in

Deno
ORG

APIs as well as built-in Node.js APIs). Here’s the full list:

Event and addEventListener have undergone a deep optimization, making them much faster; Event.timeStamp is now always set to 0

Headers was optimized for iteration and lookup scenarios, additionally validation of header names was optimized

node:http got optimizations for handling headers – IncomingMessageForServer.headers now uses caching to not compute headers on every access

node:buffer was rewritten from ground up to provide faster result when outputting strings

node:net received an optimization for socket reads, which makes npm:ws package much more performant

All these optimizations provide

up to 10%
PERCENT

more

RPS
ORG

in HTTP benchmarks.

Thank you to

Marcos Casagrande
PERSON

for implementing a lot of these optimizations.


Lockfile
ORG

v3

The

Lockfile
ORG

format has been updated to version

3
CARDINAL

.

Deno 1.37
ORG

will automatically migrate your existing

lockfile
ORG

to the new format on

first
ORDINAL

run, but loading v3 in older versions of

Deno
ORG

will error.

The new format includes information on redirects, which is used by

Deno
ORG

to lock http(s) redirects to the destination they were resolved to at the time they were inserted into the lockfile.

In this release, std/url module has been added to

the Deno Standard Library
ORG

. std/url supports various path-like operations on URLs, which are not supported by the Web standard URL methods or properties.

Currently std/url has the below

5
CARDINAL

methods:

basename

dirname

extname

join

normalize

import { basename ,

dirname
PERSON

,

extname
PERSON

, join , normalize , } from "

https://deno.land/[email protected]/std/url/mod.ts
PRODUCT

" ; const url =

new URL
PERSON

( "https://example.com/home/page.html?foo=bar" ) ; basename ( url ) ;

dirname
PERSON

( url ) ;

extname
PERSON

( url ) ; join ( "https://example.com" , "foo" , "bar.html" ) ; normalize ( "https://example.com///about///page.html" ) ;

Thank you to

Aritra Karak
PERSON

for implementing this module.


std/ulid
ORG

has been added to

the Deno Standard Library
ORG

in this release.

std/ulid
ORG

supports generating

ULID
ORG

and decoding the timestamp from the given

ULID
ORG

.

import { decodeTime , ulid } from "https://deno.land/[email protected]/ulid/mod.ts" ; const id = ulid ( ) ; const timestamp = decode ( id ) ;


ULID
ORG

is alternative to

UUID
ORG

, and because the leading part of a

ULID
ORG

is generated from a timestamp, these IDs are lexically sorted in generation time order. This property is convenient when you use it for a part of keys for

Deno KV
ORG

items.

Thank you to

Asher Gomez
PERSON

for suggesting this feature and thank you to

Lino Le Van
PERSON

for implementing it.

V8

11.8
CARDINAL

and

TypeScript
ORG

5.2.2

Finally,

Deno
ORG

v1.37 ships with

V8 11.8
PRODUCT

and

TypeScript
ORG

5.2.2.

Still want to learn more?

Believe it or not, the changes listed above still don’t tell you everything that got better in

1.37
CARDINAL

. You can view the full list of pull requests merged in

Deno 1.37
ORG

on GitHub here.

Thank you to our community contributors!

We couldn’t build

Deno
ORG

without the help of our community! Whether by answering questions in our community

Discord
ORG

server or reporting bugs, we are incredibly grateful for your support. In particular, we’d like to thank the following people for their contributions to

Deno 1.37
ORG

:

Adam Powers
PERSON

,

Alexander Michaud
PERSON

,

Curran McConnell
PERSON

,

Evan
PERSON

,

Fabian
NORP

,

Filip Skokan
PERSON

,

Jakub Jirutka
PERSON

,

Jonathan Rezende
PERSON

,

Juan Gonzalez
PERSON

,

Kira
PERSON

,

Kyle Kelley
PERSON

,

Laurence Rowe
PERSON

,

Leigh McCulloch
PERSON

,

Marcos Casagrande
PERSON

,

Shreyas
PERSON

,

Valentin Anger
PERSON

,

VlkrS
GPE

, await-ovo, lionel-rowe, osddeitf,

sigmaSd
GPE

,

zuisong
GPE

,

林炳权
GPE

, 第二扩展.

Would you like to join the ranks of

Deno
ORG

community contributors? Check out our contribution docs here, and we’ll see you on the list next time.

Thank you for catching up with our

1.37
CARDINAL

release, and we hope you love building with

Deno
ORG

!