Excessive wait times during the construction of a moderately sized application (over 2 minutes) using TypeScript and loaders like Vue-Loader and TS-Loader

I'm currently utilizing Nuxt 2 with TypeScript and the most up-to-date dependency versions available.

Even though my app is of medium size, the compilation time seems excessively slow.

Here are my PC specs: Ryzen 7 2700X (8 Cores/16 Threads) 16 GB DDR4 3000MHZ NVM-SSD

The client-compilation takes approximately 72 seconds, while the server-compilation takes around 55 seconds.

Below you can see excerpts from my package.json:

{
  "name": "nuxt",
  "version": "1.0.0",
  "private": true,
  // Dependencies list...
}

And here's a snippet from my Nuxt.config.js file:


// Import statements and configuration settings...

In addition, I have created a typescript module which includes various loader configurations for improved efficiency during the build process.

Upon running the build command with the --profile flag, it was evident that the ts-loader and vue-loader were significantly impacting the overall performance due to the high request count and time taken per request.

My project consists of approximately 44 .Vue components, all implemented in TypeScript, along with 13 .Vue pages.

If anyone has insights or suggestions on how to optimize the compilation speed, I would greatly appreciate your assistance.

Answer №2

To cut a long story short, it seems that the issue lies in type-checking being performed on the same thread as the rest of your build process. Fortunately, there is a plugin available that can separate the type-checking process onto a different thread. In my own personal project, implementing this led to a significant 4x increase in speed by following these steps:

Begin by adding the module using your preferred package manager

yarn add fork-ts-checker-webpack-plugin --dev

Then include the following in your webpack configuration:

const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
plugins: [new ForkTsCheckerWebpackPlugin()]

A sample configuration might resemble the one below:

const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

const webpackConfig = {
  context: __dirname, // for automatic discovery of tsconfig.json
  entry: './src/index.ts',
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        loader: 'ts-loader',
        options: {
          // turn off type checker - managed by fork plugin
          transpileOnly: true
        }
      }
    ]
  },
  plugins: [new ForkTsCheckerWebpackPlugin()]
};

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

Angular Application for Attaching Files to SOAP Service

I am currently utilizing soap services to pass XML data along with file attachments. While SoapUI tool works perfectly for this purpose, I want to achieve the same functionality through Angular6 in my project. Below is a snippet of my Xml code. <soap ...

How can you display the value of a date type in a TextField?

I'm currently utilizing the TextField component from material-ui. My goal is to display the current date in the TextField and allow users to select another date. Is this feasible? When using type="date", the value set as {date} does not show up in th ...

Managing and refreshing Keycloak/OpenID-Connect Claims within a client application

I am exploring the possibility of setting and updating Keycloak (OpenID-Connect) AccessToken or IdToken attributes, also known as Claims, through a client web application post successful authentication. The scenario involves adding specific user attribute ...

Struggling with transitioning from TypeScript to React when implementing react-data-grid 7.0.0

I'm trying to add drag and drop functionality to my React project using react-data-grid, but I keep encountering a "TypeError: Object(...) is not a function" error. I have a TypeScript version of the file in the sandbox as a reference, but when I try ...

"Utilizing the `useState` function within a `Pressable

Experiencing some unusual behavior that I can't quite figure out. I have a basic form with a submit button, and as I type into the input boxes, I can see the state updating correctly. However, when I click the button, it seems to come out as reset. Th ...

Trouble authenticating user through express-session with Typescript

I have developed a small app for registration and login, but I am encountering issues with using session-express to maintain the session. Check out server.ts below where I establish session, cors, etc... import express, { json } from "express"; ...

Testing a function in Angular using Karma and Jasmine

I am facing an issue while testing a method in Angular using Jasmine/Karma. The error message I keep encountering is: TypeError: undefined is not iterable (cannot read property Symbol (Symbol.iterator)) This is how I created the method: myMethod(l ...

Connect an HTML tag to information or a property

Can an HTML tag be bound to the value of a data or property in Vue 2? I experimented with different syntaxes, but none seemed to work for me. I also did some research online but couldn't find a solution. Here are a couple of examples of the syntaxes ...

Creating a unique optional string array interface in TypeScript

I am looking to create an interface that includes optional string values. Here is what I have in mind: interface IEntity { values: ['RemainingUnits', 'ActualUnits', 'PlannedUnits'] } However, when implementing this inter ...

Get React-table TS up and running on your local machine using VS Code

Objective: I am trying to get React-table working with TypeScript on my local computer. Challenge: The code is based on this page https://codesandbox.io/s/gkzg3?file=/src/makeData.ts However, when I attempt to apply the code on my local computer, I ...

The for loop displays only the most recent data fetched from Firebase

When using a for loop to retrieve a user's progress, I encounter an issue. In Typescript: this.userProgress = af.object('/UserProgress/' + this.currentUser + '/', { preserveSnapshot: true }); this.userProgress.subscribe(snaps ...

The Vuejs progressive web app service worker is failing to function offline when deployed on Heroku

I created a website using vuejs and included pwa support to make it work offline. The website is hosted on heroku and was functioning properly until recently when it suddenly stopped working offline for no apparent reason. When I run it on a local server, ...

Vue.js: UI does not update when Array Object Property is modified

Currently, I am developing a Vue.js application using version 2.6.14. The app consists of a hierarchical list of topics with the ability to have nested child topics. To render these nested topics, I am employing a recursive component. Within each topic ob ...

Dealing with URIError: Incorrect URI format encountered while using vue-router

While working on my website, I encountered a situation where appending % at the end of a URL resulted in a URIError: URI malformed. This issue sometimes caused the page to stop rendering. Despite using Vue-Router for routing, attempts with the router.befor ...

Class for Eliminating the Background Image Using Bootstrap

Is there a Bootstrap class that can be used to remove a background image from a div? Currently, I have this style defined in my CSS: background-image: linear-gradient(to bottom, rgba(0,0,0,0.1), rgba(0,0,0,0)); I would like to remove it using: bg-img-non ...

Asynchronous update of array elements - lack of firing watch events

I have recently developed a component that showcases previews of blog articles. This particular component includes pagination functionality, where selecting a new page triggers the refreshment of the article previews array. The list of articles is obtained ...

Issues with JSONPATH in typescript failing to grab any values

Searching for a specific config item validity using JSON path can be achieved by specifying the key name condition. This process works seamlessly on platforms like , accurately extracting the desired value: In Typescript, the code implementation would loo ...

Angular Toaster Notification - There are currently no toaster containers set up to display notifications

Currently, I am utilizing the angular2-toaster library within my Angular application. It is quite straightforward - you simply define a toaster container in the template of your component: <toaster-container></toaster-container> Then, you ca ...

Guide on Implementing jQuery Plugin with Vue, Webpack, and Typescript

I am currently exploring the integration of the jQuery Plugin Chosen into my vue.js/Webpack project with TypeScript. After some research, I discovered that it is recommended to encapsulate the plugin within a custom Vue component. To kick things off, I m ...

Interpolating values in Vue for key-value pairs

Imagine that in Vue.js, I have a data property named iconsColor, which is initially set to #b5ffff: data() { return { iconsColor: "#b5ffff", }; }, My goal is to utilize this property when setting the color like so: :style="{ ...