Using isolatedModules in Angular 18.2

Angular now has support for TypeScript isolatedModules as of Angular 18.2. With this support in place, we’ve seen performance boosts of up to 10% in production build times.

Published 3 months ago Viewed 0 times

We know that developers love performance improvements and in this blog post we’ll explain how you can take advantage of this feature in your projects.

Background

When using the application builder in your Angular app and the TypeScript isolatedModules option is enabled and script sourcemaps are disabled, TypeScript code will be transpiled via the bundler instead of the current behavior of using TypeScript. The use of the isolatedModules option ensures that TypeScript code can be safely transpiled without the need for the type-checker.

How it helps

Enabling this feature leads to several advantages. The bundler, esbuild in this case, now has knowledge of the TypeScript code constructs, such as enums, and can optimize the output code. It can inline both const and regular enums where possible. Additionally, this enables the removal of the Babel-based optimization passes for all TypeScript code. These passes are still present for all JavaScript code, for example code from third-party libraries/packages. These changes lead to an improvement in build time — especially in production configurations.

Effortless content and community for innovators and business minds

Join to unlock full access and engage

Members enjoy exclusive features! Create an account or sign in for free to comment, engage with the community, and earn reputation by helping others.

Create account

More posts from Angular 4Business (Official)

bizznessia.dev is a community where developers can learn business, collaborate with like-minded individuals, and turn their ideas into reality. We’re here to support you every step of the way in achieving your goals