NestJS v10 is here! What’s new?
Tags: nestjs, webdev, programming, javascript
Published: 2023-06-20 12:24:52

## SWC
1SWC (Speedy Web Compiler) is an extensible Rust-based platform that can be used for both compilation and bundling. Using SWC with Nest CLI is a great and simple way to significantly speed up your development process.

**SWC is approximately x20 times faster than the default TypeScript compiler.**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9525n68g7nf0l4g7058r.gif)


You can also use jest and vitest in combination with SWC. To learn more, check out the SWC integration recipe in the NestJS documentation.

---

## Overriding modules in tests
NestJS 10 introduces a new feature that allows you to override modules in tests. This feature is especially useful when you want to mock the entire module all at once instead of mocking each provider individually.

```typescript
Test.createTestingModule({
  ...
})
  .overrideModule(LoggerModule)
  .useModule(LoggerTestingModule)
  .compile();
```

As long as you have a LoggerTestingModule that exports the same providers as the LoggerModule (and so provides the same public API), Nest will use the LoggerTestingModule module instead of the LoggerModule in your tests.

---

## Redis wildcard subscriptions
In v10, we added support for Redis wildcard subscriptions. This feature allows you to subscribe to all messages that match a given pattern. As long as you set the wildcards configuration property to true in your microservice configuration, as follows:

```typescript
const app = await NestFactory.createMicroservice<MicroserviceOptions>(
  AppModule,
  {
    transport: Transport.REDIS,
    options: {
      host: 'localhost',
      port: 6379,
      wildcards: true, // 👈 THIS IS NEW
    },
  }
); 
```

Redis will use psubscribe/pmessage (learn more about Redis psubscribe) instead of subscribe/message under the hood. With wildcards enabled, you can use glob-style patterns in your subscriptions, as follows:

- h?llo subscribes to hello, hallo and hxllo
- h*llo subscribes to hllo and heeeello
- h[ae]llo subscribes to hello and hallo, but not hillo

---

## Cache module
The CacheModule has been removed from the @nestjs/common package and is now available as a standalone package - @nestjs/cache-manager. This change was made to avoid unnecessary dependencies in the @nestjs/common package.

---

## Dropping support for Node.js v12
As of NestJS 10, we no longer support Node.js v12, as v12 went EOL on April 30, 2022. This means that NestJS 10 requires Node.js v16 or higher. This decision was made to allow us to finally set target to ES2021 in our TypeScript configuration, instead of shipping polyfills as we did in the past.

From now on, every official NestJS package will be compiled to ES2021 by default, which should result in a smaller library size and sometimes even (slightly) better performance.

---

## CLI Plugins TypeScript >= 4.8
NestJS CLI Plugins (available for @nestjs/swagger and @nestjs/graphql packages) will now require TypeScript >= v4.8 and so older versions of TypeScript will no longer be supported. The reason for this change is that in TypeScript v4.8 introduced several breaking changes in its Abstract Syntax Tree (AST) which we use to auto-generate OpenAPI and GraphQL schemas.

Please, read more in the official website => https://trilon.io/blog/nestjs-10-is-now-available

---


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c2zcidciydse9dofz4fs.png)


[![linkedin](https://img.shields.io/badge/linkedin-0A66C2?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/kristiyan-velkov-763130b3/)

<a href="https://revolut.me/kristiyanvelkov" target="_blank">
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rxmsw2d2ooukhdg8x5ar.png)
</a>

If you like my work and want to support me to work hard, please donate via:

<a href="https://revolut.me/kristiyanvelkov" title="Link to Revolut">Revolut website payment</a> or use the QR code above.                                                                                                                           


**Thanks a bunch for supporting me! It means a LOT 😍**