Compilation in TypeScript taking longer than 12 seconds

Is anyone else experiencing slow TypeScript compilation times when building an Angular 2 app with webpack and TypeScript? My build process takes around 12 seconds, which seems excessively slow due to the TypeScript compilation.

I've tried using both ts-loader and awesome-typescript-loader, but the issue persists. Removing the loader significantly reduces the build time to around 1 second.

Research suggests that some slowness is normal during TypeScript compilation, but is a 12-second build time typical?

Past suggestions have mentioned potential conflicts with node versions; I am currently using v4.4.2.

Below is my webpack configuration code in case anyone can identify any issues. The commented out code in the Uglify section is related to a bug on the Angular 2 side:

[Webpack configuration code]

I am working on a Mac, using Angular 2 beta.15 and webpack version 1.12. Here is my tsconfig.json:

[tsconfig.json code]

Answer №1

I recommend continuing to use the awesome-typescript-loader. It offers performance-enhancing features that can be activated: a caching option and a transpile-only option:

"awesomeTypescriptLoaderOptions": {
  "useCache": true,
  "transpileOnly": true
}

Enabling both of these resulted in notable enhancements to compilation speed.

Answer №2

Discover the official wiki that offers valuable insight into best practices and troubleshooting tips for compiler performance. With extensive pages filled with information, there's a plethora of resources to aid in optimization. Here's just one recommendation:

extendedDiagnostics

Use --extendedDiagnostics when running TypeScript to obtain details on where the compiler is allocating its time.

Files:                         6
Lines:                     24906
Nodes:                    112200
Identifiers:               41097
Symbols:                   27972
Types:                      8298
Memory used:              77984K
Assignability cache size:  33123
Identity cache size:           2
Subtype cache size:            0
I/O Read time:             0.01s
Parse time:                0.44s
Program time:              0.45s
Bind time:                 0.21s
Check time:                1.07s
transformTime time:        0.01s
commentTime time:          0.00s
I/O Write time:            0.00s
printTime time:            0.01s
Emit time:                 0.01s
Total time:                1.75s

Note that even though some steps overlap, the Total time may not be the sum of all preceding times since not all tasks are measured.

The key metrics most users should focus on include:

Field Meaning
Files Indicates the number of files included in the program (use --listFilesOnly to view them).
I/O Read time Elapsed time retrieving data from the filesystem - covers traversal of included folders.
Parse time Duration spent scanning and parsing the program.
Program time Aggregate time encompassing reading from the filesystem, scanning and parsing, and other calculations related to the program graph. These stages merge because loaded files via imports and exports necessitate resolution and loading processes.
Bind time Time dedicated to generating various local semantic information within a single file.
Check time Time allotted for type-checking the program.
transformTime time Time utilized to transform TypeScript ASTs (abstract syntax trees depicting source files) into formats suitable for older runtimes.
commentTime Time spent calculating comments in output files.
I/O Write time Time taken for writing/updating files on disk.
printTime Time expended on computing the string representation of an output file and emitting it to disk.

Considering this information, you might want to inquire about:

  • If the number of files/lines of code aligns with your project's structure. Use --listFiles if necessary.
  • If Program time or I/O Read time appear excessively high, verify the correctness of your include/exclude configurations.
  • If other timings seem irregular, consider raising an issue! Diagnostic steps could involve
    • Activating emitDeclarationOnly if printTime is lengthy.
    • Referencing guidelines on Reporting Compiler Performance Issues for further assistance.

Answer №3

Kindly provide your tsconfig.json. It seems probable that you have the noEmitOnError option set to true, requiring the compiler to perform a full type check on the entire codebase before emitting anything.

Consider changing this setting to false.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The module "@angular/compiler-cli/ngcc" could not be located

When working with the following versions of Angular: I've encountered an issue when attempting to build my project using the npm run build command after switching laptops and installing a fresh copy of NodeJS and Angular. / \ _ __ __ _ ...

What is the process for creating a new type from a nested part of an existing type?

Currently, my website is being developed with a focus on utilizing code generation to ensure type safety when handling GraphQl queries. Certain components within the application receive a portion of an object as a prop. The specific type structure is outli ...

Unable to establish a simulated environment and trial period for experimentation

I encountered the following errors during the test: TypeError: Cannot read properties of undefined (reading 'subscribe') Error: <toHaveBeenCalled> : Expected a spy, but got Function. I am having trouble understanding these errors. Here i ...

Best practices for transferring date objects between a frontend developed in JavaScript/TypeScript and a backend built in ASP.net Core 5

An exciting project I am working on involves a web application with a backend REST web API developed in ASP.net Core 5 and a frontend Angular application written in TypeScript. One of the APIs from the ASP.net backend returns an instance of a C# object de ...

How can I refresh the information in the navbar in Angular2?

Looking for guidance on the following scenario: I am working with two distinct components called navbar and homepage. The navbar has a specific area designated for displaying the city name. Within the homepage component, there is a form that includes a ...

Errors in the @babel/types during the ng build process in Angular version 8.2.14

When I execute the command 'ng build' for my Angular App, I encounter the following errors: ERROR in ../node_modules/@types/babel-types/index.d.ts:1769:96 - error TS1144: '{' or ';' expected. 1769 export function assertArrayE ...

Obtaining the value of an ion-toggle in Ionic2 using the ionChange

Below is the toggle I am referring to: <ion-toggle (ionChange)="notify(value)"></ion-toggle> I am looking for a way to retrieve the value of the toggle when it is clicked in order to pass it as a parameter to the notify method. Any suggestion ...

What is the reason for TypeScript allowing this promise chain without any compilation errors?

Although I am still relatively new to Typescript, I find myself grappling with a particular issue that has been perplexing me. I am unsure why the following code snippet triggers a compilation error: // An example without Promises (does not compile) funct ...

The Jasmine test in my Angular project is experiencing a timeout issue, displaying the error message "Async callback was not invoked within 5000ms", despite the fact that no async function is being used in the

Reviewing the source code: import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { IonicModule } from '@ionic/angular'; import { HomePage } from './home.page'; import { LevelGridComponent } from &a ...

How to use TypeScript to set a value in ng2-ckeditor

I have implemented two ckeditor instances using *ngFor: <div class="form-group" *ngFor="let lang of languages"> <span>Legal text in {{lang.translate}} {{lang.abbr}}</span> <ckeditor id="{{lang.abbr}}" formControlName="{{lang.abbr} ...

The initial processing step for the export namespace is to utilize the `@babel/plugin-proposal-export-namespace-from` plugin. Previous attempts to resolve this issue have been

I encountered a problem with my application and found two related questions on the same topic. However, due to a lack of reputation, I am unable to comment or ask questions there. That's why I'm reaching out here... Recently, I integrated Redux ...

Guide to adding a custom font to your Angular 5 project

I am looking to integrate a new font into my Angular 5 project. So far, I have attempted: 1) Moving the file to assets/fonts/ 2) Including it in the styles section of .angular-cli.json However, it seems that the file is not a regular .css file; it is a ...

Transmitting form data inputted by the user to a modal that resides in the same component, all without the need for child or parent components or

In need of a solution where users can input answers to questions and have all the entered data displayed in a popup alongside the respective question. If a user chooses not to answer a question, I do not want that question or any related information to be ...

Optimizing performance by serving Vue JS chunks lazily from a CDN

I am currently working on a single-page application built with Vue.js 3 and managed by Vue CLI 5 (Webpack 5). The application is hosted within a Laravel app, which is deployed on AWS through Laravel Vapor. Using this tool, all static assets, including JS c ...

Is there a circular dependency issue with ManyToMany relationships in Typescript TypeORM?

Below are the entities I have defined. The Student entity can subscribe to multiple Teachers, and vice versa - a Teacher can have many Students. import { PrimaryGeneratedColumn, Column, BeforeInsert, BeforeUpdate } from "typeorm" /* * Adhering to ...

Sharing data between two components in Angular 7

The Address object values are not being retrieved as expected when requesting from the credit card component to a function called getAddress() in a config service that holds the value. Instead of the updated values, I am getting the initial values. Below i ...

Loading Highcharts in Angular app

I'm currently using a highchart donut chart, but it's loading before the API response comes in. This is causing the data not to render properly. I need to retrieve the value of this.Total_connect in the highchart. Also, I want to access the val ...

The double curly brackets in Angular for text interpolation are failing to work, causing the variable values to not be shown on display

I'm having trouble getting the details of a student to display on my app. Here's the code: import { Component, OnInit } from '@angular/core'; import { Student } from '../student'; import { ActivatedRoute } from '@angular/ ...

Guide on how to conditionally display a button or link in a Next.js Component using TypeScript

Encountering a frustrating issue with multiple typescript errors while attempting to conditionally render the Next.js Link component or a button element. If the href prop is passed, the intention is to render the Next.js built-in Link component; otherwise, ...

Angular 8 form controls becoming unresponsive while the list is being loaded

Hello, I am currently experiencing an issue in Angular. I have a page with a basic Angular form and two independent components that load lists from an API (comments with 500+ records and posts with 500+ records). The Problem: While trying to enter values ...