BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News AdonisJS v6 Released: TypeScript, ESM, and beyond

AdonisJS v6 Released: TypeScript, ESM, and beyond

AdonisJS, a Node.js web application framework, has released its latest major release, AdonisJS v6. Notable highlights include a transition to ECMAScript Modules (ESM), an improved and simplified IoC container, improved TypeScript integration, and a more straightforward approach to route and controller binding. Additionally, the release introduces a new validation library called VineJS, Vite integration for bundling frontend assets, and an overhauled scaffolding system with a codemods API.

One of the key highlights of AdonisJS v6 is the migration to ECMAScript Modules (ESM) and TypeScript, aligning the framework with modern JavaScript standards. This move ensures compatibility with the latest versions of packages and enhances security by allowing the use of the latest security fixes. AdonisJS v6 applications will now use TypeScript and ESM by default, though users can still install and use packages written in CommonJS.

The release also bids farewell to TypeScript compiler hooks, a notable feature in AdonisJS v5. In v6, the framework eliminates the need for these hooks, resulting in regular JavaScript imports without relying on the official TypeScript compiler API. This change simplifies the codebase and allows developers to choose other Just-In-Time (JIT) tools like ESBuild or SWC.

AdonisJS v6 enhances type safety by improving routes, controllers, middleware references, AdonisRC files, and event emitters. Direct imports replace magic strings in routes and controllers, resulting in improved type safety and code readability. Named middleware references and AdonisRC files are now managed through TypeScript references, contributing to better code intelligence and an improved developer experience.

Another noteworthy enhancement in AdonisJS v6 is the introduction of class-based events. Developers can now define events as classes, encapsulating both the event identifier and data within a single class. This approach enhances type safety and provides a cleaner way to structure events in the application.

AdonisJS v6 embraces Vite as the official frontend bundler, moving away from recommending Webpack Encore for new projects. The release also brings a new scaffolding system and codemods API, providing a more streamlined and efficient way to configure packages and scaffold resources. In addition, it introduces VineJS as the official validation system. VineJS aims to offer improved speed, comprehensive features, and a more developer-friendly API compared to the previous validation module.

The documentation for AdonisJS was also improved in the release, covering previously undocumented topics like IoC Container and Service providers. The framework aims to provide developers with comprehensive guides and references to facilitate a smoother learning curve.

Looking ahead, the AdonisJS team outlined future plans for AdonisJS v6. The focus will be on stabilizing the framework, fixing bugs, and improving the migration guide. Several packages, such as Drive, Limiter, Lucid Slugify, Attachment Lite, Route model binding, and Health checks, are expected to be migrated to AdonisJS 6 in the coming weeks.

About the Author

Rate this Article

Adoption
Style

BT