Deno 2 Release Candidate Ready
Written by Ian Elliot   
Thursday, 26 September 2024

The Deno team has released the release candidate for Deno 2.0, which includes everything expected in the final release. This is the largest update since 1.0 back in May 2020, with major changes like the introduction of Node's process global.

Deno is built in Rust, and is described as secure by default as it has no file, network, or environment access, unless explicitly enabled. 

deno

Deno is targeted to be an alternative to Node.js, but so far isn't as widely adopted, despite offering native support for TypeScript and ECMAScript modules.

One major change to Deno 2 is in the handling of global variables. The window global has been removed, and Node's process is now available. Deno added the window global in Deno v1.0, with the aim of making Deno as browser-compatible as possible. This backfired, as many libraries check if they are executed in the browser by probing for a window global variable instead of checking for the existence of DOM. This led to a class of bugs in libraries that would otherwise work in Deno, due to window being globally available.

While window has been removed, the process global has been added as per user requests. The Deno developers say that while it has been possible to use process by importing it from node:process module for a long time, many popular frameworks rely on its presence in the global scope. The addition should mean that more code written originally for Node.js will work with no changes in Deno.

Other changes improve dependency management, and several important APIs are now included in stable versions upgrading eh previous unstable options. This includes WebGPU, the JavaScript API from web browsers for efficient use of a device's graphics processing unit. Other improved APIs include FFI (foreign function interface) APIs used to call native code, and createHttpClient.

There's also improved support for CommonJS. Previous versions of Deno have offered only limited support for CommonJS through manual creation of require.

In a statement about the release candidate, the Deno team said:

"While we firmly believe that ES modules are the future of JavaScript, the landscape in 2024 still includes numerous libraries and projects relying on CommonJS."

In the light of this, several improvements have been made in Deno 2 to help working with CommonJS modules and make transition to ES modules easier. Most importantly, Deno can now execute CommonJS files, provided that they use the .cjs extension. Deno does not look for package.json files and type option to determine if the file is CommonJS or ESM.

The final change of note is that import assertions have been dropped in favor of import attributes. This change has been made because the proposal has undergone major changes, including updating the keyword from assert to with, and being renamed to Import Attributes. In addition, some browsers (eg. Chrome) have already removed support for Import Assertions.

Deno 2.0 release candidate is available now.

deno

More Information

Deno Website

Related Articles

Deno Adds Support For Private npm Registries

Deno Improves JSR Support

Deno Supports Built-in Node Modules

Deno 1.28 Stabilizes NPM Compatibility

Deno Joins ECMA

Node.js Even Its Creator Thinks Its Flawed 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Eclipse Foundation Launches Open Regulatory Compliance Working Group
24/09/2024

The Eclipse Foundation has announced the formation of the Open Regulatory Compliance Working Group (ORC WG), which they say will support participants across the open source community in navigating and [ ... ]



Pulumi Envisions The Intelligent Cloud
18/09/2024

Today at PulumiUp, its 4th annual conference, Pulumi is announcing "Intelligent Cloud", its vision for AI-powered cloud infrastructure, and two new products, ESC GA and Insights 2.0.  


More News

kotlin book

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Thursday, 26 September 2024 )