ITS
Node.js development
Introduction
Node.js 20 is here with its latest features and new updates taking the developer community to another level of excitement. This time the development team at Node has kept the Node 20 release date on April 18, 2023. As the Node community follows the event conventions, Node.js 20 will be promoted to Long-Term Support or LTS version in October 2023. and will be supported until April 2026. But, considering What’s New in Node 20 Features and Updates, let us move ahead to learn more.
The latest Node version 20 has come up with a number of upgrades and features from the previous version in terms of performance, error handling, and many more. Let us present all these latest features and updates of Node.js 20 in detail:
The Permission Model feature is furnished to Node.js v20 by Rafael Gonzaga. It is an experimental mechanism introduced to enable developers to restrict access to specific resources, such as file child process spawning, system operations, and worker thread creation, simultaneously with their program running.
To access this feature, the developers must enable the –experimental-permission, which will restrict access to all the available permissions. With this feature, developers can avoid unwanted access or alteration of sensitive data or the execution of harmful code in their applications.
To learn more about the Permission Model, check out the Node.js documentation.
The Custom hooks supplied via loaders (–experimental-loader=./foo.mjs) now have a dedicated thread to run, separated from the main thread delivering a different scope for loaders and ensuring no cross-contamination between loaders and application codes.
With the contribution of Michaël Zasso, a new version of the V8 engine is included in the Node.js 20. Here, the V8 engine is updated to version 11.3, a part of Chromium 113 that brings performance enhancements and new language features such as:
The Node.js team has brought some exceptional performance enhancements with the new version of Node.js. The newly formed Node.js Performance team has focused on performance enhancements since the last major release. Also, Node.js 20 has brought about several refinements to the fundamental parts of the runtime, including URL, fetch(), and EventTarget.
The cost to initiate Even Target is reduced to half, along with faster access to all subsystems using it. Also, the V8 Fast API calls offer improved performance in APIs such as URL.canParse() and timers.
With the contribution of Yagiz Nizipli and Daniel Lemire, the latest version of the URL parser written in C++, Ada has been included in Node.js v20 resulting in significant improvements in URL parsing performance. The upgrade in node:url enhances the url.domainToASCII and url.domainToUnicode functions. The latest Ada 2.0 integration in Node.js 20 across all aspects of the Node.js application ensures better performance than its previous version, Ada 1.0.4, and eliminates the ICU prerequisite in URL hostname parsing.
The Node.js team has been working on support for SEAs or the Single Executable Applications over the last year, with initial support landing recently; the team continues to make this better as the feature is still experimental. However, in Node 20, building a Single Executable App now requires injecting a blob prepared by Node.js from a JSON config rather than injecting the raw JavaScript file.
Example:
sea-config.json
{
“main”: “hello.js”,
“output”: “sea-prep.blob”
}
This writes the blob to the sea-prep.blob file.
Another great function in the Node.js 20 version is the coercion and validation of arguments of Web Crypto API functions as per their WebIDL definitions which is identical to the other implementations of the Web Crypto API and fosters interoperability. The goal here is to focus on interoperability with other JavaScript environments.
With the input of Stefan Stojanovic, ARM64 Windows is upgraded to tier 2 support. And thus, Node v20 now includes the ARM64 Windows binaries, which allows for native execution on the platform. Like other platforms, the Node.js download site provides access to the MSI, zip/7z packages, and executable files. Also, the CI system has undergone an upgrade to facilitate full testing on ARM64 Windows, thereby preventing any regressions and ensuring compatibility. Stefan Stojanovic was responsible for elevating ARM64 Windows to tier 2 support.
The Node.js development team continues to progress on the WASI or Web Assembly System Interface implementation; though it is experimental, the command line option is not needed to enable WASI, which will make it easier to consume. As the team working dedicatedly on WASI gears up to preview2, several changes have been implemented to ensure compatibility with future versions. Also, a version option has been added when creating a new WASI() instance, added when creating a new WASI() instance, and in the 20.x release, specifying a version is mandatory as there is no default value. While this improves support for new versions, it requires updating any code that relied on the default version. The development team invites additional contributors interested in using WASI in Node.js or uvwasi, which is used outside the Node.js environment.
In Node.js 20 update, url.parse() has been deprecated at runtime with invalid ports, as denoted by [3bed5f11e0] – (SEMVER-MAJOR) in the codebase. This is because url.parse() permits URLs with non-numeric ports, which could lead to unexpected input and potentially facilitate hostname spoofing. To mitigate these risks, future versions of Node.js, starting from Node.js v20, will throw an error if such URLs are encountered. This aligns with the WHATWG URL API, which already follows this approach. As of Node.js 20, url.parse() will issue a warning for such URLs.
This is what the latest Node v20 version brings to the table. This blog post must have given you significant insight into the latest features and updates of Node 20. However, if you are a business owner using Node.js for your web application development and unsure if you should upgrade to the latest version of Node, then you can Hire Node.js development company like Bacancy to help you gain conviction and make the right choice based on your project needs and requirements.