BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News NestJS 12: ESM Packages, Standard Schema Validation and Native Observability

NestJS 12: ESM Packages, Standard Schema Validation and Native Observability

Listen to this article -  0:00

NestJS, the TypeScript framework for building server-side Node.js applications, has released version 12, a major release that moves its core packages to ESM, adds first-class Standard Schema validation, rebuilds the CLI and introduces an official observability SDK. It follows April's roadmap, and creator Kamil Myśliwiec's announcement on X has passed 1,100 likes and 66,000 views.

The ESM change is the headline, largely because it asks so little of existing teams. Core packages now ship as ESM, but CommonJS applications keep working through Node.js require(esm) support, which is why v12 requires Node.js 20.19+ or 22.12+. nest new now asks whether to generate a CJS or ESM project, with ESM projects defaulting to Vitest and oxlint, while Rspack replaces webpack as the monorepo bundler. Developer Anton Chapala's preview benchmarks found no meaningful startup or memory gains from ESM, concluding it "is a massive cleanup of tooling and configuration debt" rather than a performance upgrade.

Day-to-day ergonomics change most around validation. Route decorators such as @Body(), @Query() and @Param() accept a schema option taking any Standard Schema compatible object, so Zod, Valibot and ArkType work without third-party wrappers once the new pipe is registered.

class-validator remains the documented default. Blogger iiaku argued that building on a spec rather than on Zod directly "keeps the choice in my hands while removing the boilerplate", though a commenter on ByteIota's preview coverage noted that types must still be annotated by hand because Nest continues to rely on legacy TypeScript decorators.

The most debated addition is @nestjs/observe, which hooks into Nest's own lifecycle through a new instrument option instead of patching the HTTP server, reporting traces in terms of controllers and providers. APM vendor Scout Monitoring acknowledged the richer context but warned the SDK is "NestJS-only", lacks cross-stack correlation out of the box and risks "vendor lock-in at the framework level". A new nest deploy command, forwarding to the Mau platform, points the same way towards first-party services.

observe-dashboard.png

The NestJS Observe dashboard, source: Trilon

Upgrading from v11 means installing the latest CLI with npm i -g @nestjs/cli@latest and running nest upgrade, which moves every @nestjs/* package to v12, bumps TypeScript to v6 and applies mechanical changes such as the GraphQL Playground to GraphiQL switch and the NATS v3 client swap.

It deliberately does not convert projects to ESM, Vitest or oxlint. The migration guide covers the rest, including lifecycle hook ordering and Joi v18.

One GitHub issue prompted docs noting AWS Lambda runtimes need --experimental-require-module, while others report path aliases breaking under ESM and Fastify middleware exceptions hanging. The follow-up v12.1 has since added built-in cookies, CSRF protection and security headers.

NestJS is an open-source, MIT-licensed framework for building efficient and scalable server-side applications with TypeScript. It combines an Angular-inspired module and dependency injection architecture with Express and Fastify support, and has more than 76,000 stars on GitHub.

About the Author

Rate this Article

Adoption
Style

BT