mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-22 06:41:45 +08:00
When using the application builder 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. This mode of operation has several advantages. The bundler (esbuild in this case) will know have knowledge of the TypeScript code constructs, such as enums, and can optimize the output code based on that knowledge including inlining both const and regular enums where possible. Additionally, this allows for the removal of the babel-based optimization passes for all TypeScript code. These passes are still present for all JavaScript code such as from third-party libraries/packages. These advantages lead to an improvement in build time, especially in production configurations. To ensure optimal output code size in this setup, the `useDefineForClassFields` TypeScript option should either be removed or set to `true` which enables ECMAScript standard compliant behavior. Initial testing reduced a warm production build of a newly generated project from ~2.3 seconds to ~2.0 seconds.
Angular Build System for Applications and Libraries
The sources for this package are in the Angular CLI repository. Please file issues and pull requests against that repository.
Usage information and reference details can be found in repository README file.