Compiling with tsc --build compared to tsc --project

I'm currently working on converting a subproject to TypeScript within my monorepo. Within my npm scripts, I initially had:

"build-proj1":"tsc --build ./proj1/tsconfig.json"

Although it did work, I noticed that the process was unusually slow.

After making a simple adjustment to:

"build-proj1":"tsc --project ./proj1/tsconfig.json"

The execution speed significantly improved while producing the same outcome...

Below is my tsconfig.json for reference:

{
    "compilerOptions": {
        "allowSyntheticDefaultImports": true,
        "module": "CommonJS",
        "target": "es2018",
        "lib": ["es2019"],
        "noImplicitAny": false,
        "declaration": false,
        "allowJs": true,
        "preserveConstEnums": true,
        "outDir": "./dist",
        "sourceMap": true,
        "skipLibCheck": true,
        "baseUrl": "./",
        "types": ["node"],
        "typeRoots": ["../node_modules/@types"],
        "strict": true,
        "esModuleInterop": true,
        "disableReferencedProjectLoad": true,
        "paths": {
            "root-common/*": ["../common/*"],
            "root-config/*": ["../config/*"],
            "root/*": ["../*"]
        }
    },
    "include": ["./**/*"],
    "exclude": ["node_modules", "**/*.spec.ts", "**/*.test.*", "./dist/**/*", "../common/**/*test.*"]
}

My inquiry pertains to understanding the distinction between using --build and --project, as well as why --build runs considerably slower than --project?

Answer №1

As stated by tsc --help:

  --project, -p  Compile the project specified by its configuration file path or a folder containing 'tsconfig.json'.

  --build, -b  Compile one or more projects and their dependencies if they are outdated

The --project option compiles a single project.

The --build option acts as a build coordinator that identifies referenced projects, verifies their status, and compiles any outdated projects in the correct sequence. Refer to the documentation for more information.

To address your second inquiry, the --build option is slower because it also compiles dependencies. However, subsequent runs should be faster as it only compiles projects that are not up-to-date.

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

JavaScript: exporting everything from ... causing excessive bloat in the build file

After building my react-app with create-react-app, I noticed a decline in performance. Here is the structure of my project: /store actions.ts reducers.ts /module1 module1.actions.ts module1.reducers.ts /moduleN moduleN.actions.ts m ...

Creating a default option in a Select tag with React when iterating over elements using the map method

After learning that each element in the dropdown must be given by the Option tag when using Select, I created an array of values for the dropdown: a = ['hai','hello','what'] To optimize my code, I wrote it in the following ...

My current setup includes Node.js version 8.11.2 and Angular CLI version 7.1.2. However, upon running Angular CLI 8.0+, it displays an error stating "You are running version v8.11.2 of Node.js, which is not supported

From the beginning of my project, I encountered a version error which led me to uninstall and delete all Node and CLI files before reinstalling them. However, now when I try to run npm start, I am faced with the following message: The current Node.js vers ...

Is it possible to refresh the component view using the service?

I am interested in developing a NotificationService that will be utilized to showcase a notification from another section. My inquiry is, how can I refresh the view of a component using a service? My ultimate goal is to have the capability to embed a comp ...

Unit testing the TypeScript function with Karma, which takes NgForm as a parameter

As I work on writing unit tests for a specific method, I encounter the following code: public addCred:boolean=true; public credName:any; public addMachineCredential(credentialForm: NgForm) { this.addCred = true; this.credName = credentialForm.val ...

What makes TS unsafe when using unary arithmetic operations, while remaining safe in binary operations?

When it comes to arithmetic, there is a certain truth that holds: if 'a' is any positive real number, then: -a = a*(-1) The Typescript compiler appears to have trouble reproducing arithmetic rules in a type-safe manner. For example: (I) Workin ...

What is the process for retrieving the chosen country code using material-ui-phone-number?

When incorporating user input for phone numbers, I have opted to utilize a package titled material-ui-phone-number. However, the challenge arises when attempting to retrieve the country code to verify if the user has included a 0 after the code. This infor ...

Having issues installing Parcel through npm - Encountered an error while parsing package.json information

After creating a package.json file using the command npm init in my project folder, I proceeded to run npm i parcel --save-dev which resulted in an error message: C:\Users\XPRESS\Desktop\starter>npm i parcel --save-dev npm ERR! code ...

The Vue component's TypeScript object prop type does not match the expected value

Having trouble with the type of Object properties in Vue Single File Components using TypeScript (created with Vue CLI 3)? Check out the example below to see the issue. The type of this.product is currently showing as (() => any) | ComputedOptions<a ...

Methods for updating packages within node_modules

Is there a way to update packages that are in my node_modules but not listed in the dependencies? I attempted using npm install --sace --legacy-peer-deps <package-name>, but it ended up adding the package to my dependencies. ...

Are dependencies necessary once webpack has bundled my code?

As my project is bundled by webpack, I am questioning whether dependencies are necessary or if everything can be categorized as devDependencies. I have successfully created a react component library and published it on npm. The peerDependencies listed inc ...

Encountering the error message "npm ERR! code ENOVERSIONS" while trying to create a new

Issues persist when launching a new Angular project. npm ERR! code ENOVERSIONS npm ERR! No valid versions available for timed-out For example:- ng new training-app installing ng2 create .editorconfig create README.md create ...

Using the ternary operator for rendering components in TSX: A beginner's guide

Currently, I am retrieving data from a server. The component to display is determined based on the result of this retrieval process. const response = fetch(url) .then((result) => result.json()) .then((data) => data) .catch((e) => { ...

"Modifying Code Aesthetics in WebStorm/IDEA: A Step-by-

Here is the code style I am currently using in my JavaScript project: var obj = { a: 1 , b: 2 , c: 3 } var arr = [ 'a1' , 'a2' , 'a3' ] const w = 1 , w2 = 2 , w3 = 3 The team claims they are following npm's co ...

Setting up pagination in Angular Material can sometimes present challenges

After implementing pagination and following the guidelines provided here. This is my code from the app.component.ts file - import { Component, OnInit, ViewChild } from '@angular/core'; import {MatPaginator} from '@angular/material/paginat ...

Having issues with yarn while trying to install node-sass

I recently joined a Web project that utilizes yarn instead of npm. It involves additional libraries and configurations that I am not familiar with. The issue I am facing is related to installing node-sass using yarn on my machine. yarn add node-sass Howev ...

Is it time to refresh the sibling element when it's selected, or is there

I have recently started working with react and TypeScript, and I am facing some challenges. My current task involves modifying the functionality to display subscriptions and transactions on separate pages instead of together on the same page. I want to sh ...

Browserify Rails encountered an error - ParseError: Error with 'import' and 'export'. These statements can only appear with 'sourceType: module'

Recently, I encountered an issue while trying to integrate an NPM package into my Rails application. The problem I'm facing can be seen in the following image: https://i.stack.imgur.com/cIOw8.png I searched this forum for similar issues but found tha ...

The interface does not allow properties to be assigned as string indexes

Below are the interfaces I am currently working with: export interface Meta { counter: number; limit: number; offset: number; total: number; } export interface Api<T> { [key: string]: T[]; meta: Meta; // encountered an error here } I h ...

Issue with Next.js: Callback function not being executed upon form submission

Within my Next.js module, I have a form that is coded in the following manner: <form onSubmit = {() => { async() => await requestCertificate(id) .then(async resp => await resp.json()) .then(data => console.log(data)) .catch(err => console ...