• 0030 2107517586
  • info@wizdom.gr

Node.js v19: What’s New?

Node.js v19: What’s New?

Node.js v19: What’s New?

 

The since the first release of the Node.js framework which is based on the foundation of JavaScript (JS), it has unearthed a huge potential for web-app and API developers to uncloak and create applications that change the world, with the utmost focus on efficiency and functionality, Node.js is one of the most reactive and responsive frameworks of JavaScript that allow for both back and front-end ops.

 

Node.js is a runtime environment for web-applications which makes use of JavaScript on the back-end and works on the principles of asynchronous development powered by the V8 engine. It is completely open-source with regular commits in its repository by developers and contributors all around the world.

 

With its dawn in 2009, it has escalated to a global extent with developers and web-designers around the world utilising the framework to further their efforts. Through 2009 and 2015, NPM (Package Manager) v1.0 was released, the support of ES6 modules went global and the support of Yarn (Package Manager) was introduced and much later on in 2017, V8 (Google’s Engine) specified Node.js as the primary target for JS engines.

The Recent Developments

With the latest v19 of Node.js released, it brought about some important changes in terms of networking and server-side support, a large quantity of commits and some minor roll-backs were witnessed after the release. Node.js v19.0.0 is the “Current” release with the “LTS (Long-Term Support)” coming later this month as of October, 2022.

What Actually Has Changed

Starting with the depreciations and removals of modules from the Node.js package, following are the APIs/Functions that have been deprecated/removed from Node.js v19.0.0.

 

  • Runtime package import/export depracation, with use of double slashes either "/" or "\". It will no longer present a validation error while importing packages.

           

            It will no longer present an error in the following syntax:

 

            import "module-alias/register";

 

Either starting or ending with a slash, all restrictions and errors proposed on slashed imports are now deprecated and developers will now be able to use the afore-mentioned syntax.

 

  • Runtime coercion to integer in process.exitCode or process.exit(). Any value passed to the latter other than null, undefined or an integer as parameters will be deprecated.

 

            This update has been removed/deprecated from v19.0.0 henceforth.

New Updates

Some of the new updates that are carried on/updated from v18 of Node.js have resulted in a huge improvement in the networking and efficiency sector of Node.js, making it a more agile and a speedy solution to development of applications.

1.  HTTP(S)/1.1 KeepAlive Function

The Keep-Alive function in Node.js was not enabled by default and v19.0.0 has changed just that by setting the function as default with a default waiting-time of 5 seconds. This would allow the HTTPS requests to pass for a greater amount of time and significantly reduce the waiting times for network-intensive applications, here is a simple script that requires enabling of Keep-Alive

 

const got = require('got');
const https = require('https');

https.globalAgent = new https.Agent({ keepAlive:true });

const main = async () => {
const r1 = await got('https://yoursite/');

console.log(r1.timings.phases);

const r2 = await got('https://yoursite/');

console.log(r2.timings.phases);
};

 

In the v19.0.0 update, both https.global and https.globalAgent have Keep-Alive turned on by default.

2.  Updated V8 Engine to v10.7

The new V8 10.7 being part of the new Chromium 107 has brought about a new feature to the JavaScript API of Intl.NumberFormat. The update further optimises the API which returns an array of string objects paired with a number with further features such as:

 

  • formatRange()
  • Intl.NumberFormat.prototype.formatRangeToParts
  • Intl.PluralRules.prototype.selectRange

 

  • A source property with startRange, shared and endRange functions.

 

Utilise the following code to check the newer functions out :

 

const n1 = new Intl.NumberFormat("en-US", {
style: "currency",
currency: "EUR",
maximumFractionDigits: 0,
});
n1.formatRange(3, 5);

 

Here, in nf.formatRange(3, 5), the (3,5) depict the startRange and endRange variables. Peer method have also been introduced in the structure of the API:

 

const n2 = new Intl.PluralRules("sl");
n2.selectRange(115, 211);

 

3.  llhttp 8.1.0 Update

llhttp has been updated to version 8.1.0 and the new update comes with changes in the callback functions, the update has introduced newer callbacks and now allows the existing callback functions in applications to be paused at command.

 

This greatly affects the networking efficiency of applications during communication on the web. llhttps is approximately 116% more efficient and faster than the regular http_parser

4.  Removal of Dtrace/ETW/SystemTap

The removal of said tools was simply triggered by a lack of resources from the Node.js team, as is depicted in their release docs. Although the issue was raised in the repository, there is a visible chance that support for Dtrace/ETW and SystemTap will be made live in the future updates after v19.0.0. These tools did not incorporate proper integration with the Node.js repository and hence were proving to be a source of problems and inefficiencies in codes and applications which in turn affected the applications using these resources in a negative manner.

 

Apart from the afore-mentioned major updates, there are a number of other SEMVER commits that are not quite as visible as the latter. These updates include functions and corrections for the proper integration of V8 with operating systems. Corrections and optimisations of tools and commands that have been updated to better integrate with the development environments.

 

Some minor SEMVER commits also include the integrations of -import flag, diagnostic channels for process and workers, support for external JS (JavaScript) built in modules, initial shadow realm support and the addition of maxArrayLength to Set and Map.

 

All updates and commits are made by individual contributors as Node.js is an open-source repository and anyone can suggest and commit valid changes and updates, once they are approved by the Node.js team, they are implemented in the upcoming update for the framework.