Introduction
Exciting news for Node.js enthusiasts – NestJS 10 is officially here! This release is not just a routine update; it’s a game-changer with a plethora of bug fixes, enhancements, and intriguing features. If you’re not acquainted with NestJS, it’s a TypeScript Node.js framework designed to facilitate the creation of efficient and scalable enterprise-grade applications.
Let’s delve into the highlights:
SWC Integration
NestJS 10 now seamlessly integrates with SWC (Speedy Web Compiler), a Rust-based platform for lightning-fast compilation and bundling. Boost your development process by up to 20 times with the simple addition of the -b swc flag to the nest start command.
$ nest start -b swc
Or by setting the compilerOptions.builder property in your nest-cli.json file, as follows:
{
"compilerOptions": {
"builder": "swc"
}
}
Vitest Testing Integration
Vitest, a swift test runner tailored for Vite, joins forces with NestJS. Offering a modern and efficient testing solution, Vitest can be effortlessly integrated into your NestJS projects, enhancing your testing experience.
Module Overriding in Tests
NestJS 10 introduces a novel feature allowing module overrides in tests. Simplify mocking by overriding entire modules in tests, providing a streamlined approach for mocking modules with numerous providers.
Test.createTestingModule({
...
})
.overrideModule(LoggerModule)
.useModule(LoggerTestingModule)
.compile();
If you have a LoggerTestingModule mirroring LoggerModule's providers, Nest uses it in tests. Overriding test modules simplifies mocking complex modules with many providers.
Redis Wildcard Subscriptions
Version 10 introduces support for Redis wildcard subscriptions, enabling subscription to messages matching specific patterns. Configure your microservice to use wildcards and enjoy the flexibility of glob-style patterns in your subscriptions.
const app = await NestFactory.createMicroservice<MicroserviceOptions>(
AppModule,
{
transport: Transport.REDIS,
options: {
host: 'localhost',
port: 6379,
wildcards: true,
},
}
);
Redis employs psubscribe/pmessage (details in Redis psubscribe). Enabled with wildcards, embrace glob-style patterns in subscriptions:
- h?llo for hello, hallo, and hxllo;
- h*llo for hllo and heeeello;
- h[ae]llo for hello and hallo (not hillo).
CacheModule Standalone Package
The CacheModule bids farewell to @nestjs/common and now stands as a standalone package – @nestjs/cache-manager. This strategic move minimizes unnecessary dependencies in @nestjs/common.
For more info Click Here.
Node.js v12 No More
NestJS 10 drops support for Node.js v12, pushing for Node.js v16 or higher. This decision aligns with setting the target to ES2021 in TypeScript configuration, leading to a smaller library size and potential performance improvements.
CLI Plugins and TypeScript >= 4.8
CLI Plugins for @nestjs/swagger and @nestjs/graphql now require TypeScript >= v4.8. This shift accommodates changes introduced in TypeScript v4.8, enhancing schema generation for OpenAPI and GraphQL.
Ready to Upgrade?
Migration from Nest v9
In order to migrate your existing project, follow the guidelines that are available here. Also, make sure to get rid of all deprecation messages that may appear in your console.
Conclusion
Nest.js v10 is more than just an update; it’s a leap forward in the evolution of this powerful framework. From performance enhancements to improved developer tools, the latest version is designed to elevate the development experience. If you’re a Nest.js enthusiast or someone looking to explore a modern, opinionated framework for building server-side applications, diving into Nest.js v10 is a journey worth taking. Upgrade now and discover the unparalleled capabilities that await you in this latest release.
For more detail checkout the NestJS documentation.
With these thank you if you were there till the end. For more such blogs and updates follow Front-end Competency.
Follow NashTech Blogs for more amazing blogs.