The Node.js project relies heavily on testing to ensure quality, and this release focuses on improving the test runner. Support for passing globs allows more flexible targeting of test files. A new parallelism CLI flag gives developers more control over running tests in parallel to take advantage of multi-core systems.
An exciting new addition in Node.js 21 is the stabilization of WebStreams. This API allows the processing of data in small chunks, which is useful for browser applications. According to Gonzaga, “WebStreams opens new possibilities to bring Node. js-style asynchronous streaming interfaces to the browser.”
“Our goal is to eventually find a way to support ES module syntax by default with minimal breaking changes,” said Gonzaga. The flag allows developers to preview this future direction.
Under the hood, several performance optimizations have been implemented. File system operations such as fs. stat and fs. access is faster. Streaming data through zlib is speedier and HTTP parsing and header validation are more efficient.
For the complete details on all updates in Node.js 21, developers can refer to the official release notes here.