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

React refs should always be validated for null or never values to avoid any potential issues

As I set up a react ref to be used in useEffect, the compiler is throwing an error stating that myRef.current evaluates to never: import React, {useRef, useState} from 'react' export default function RefProblem() { const myRef = useRef(null ...

Join our mailing list for exclusive updates on Angular 6

ingredients : Array additionalIngredients : Array In my code, I have two different methods for subscribing: this.ingredients.valueChanges.subscribe(val=> { console.log(val); } this.additionalIngredients.valueChanges.subscribe(val2=> { console.lo ...

Manipulate values within an array when a checkbox is selected or deselected

I am developing an Angular application where I have created a checkbox that captures the change event and adds the checked value to an array. The issue I am facing is that even if the checkbox is unchecked, the object is still being added to the array. D ...

Encountered an error in verifying host key while trying to install NPM module from a private Bit

I encounter an issue while attempting to install an NPM module from a private Bitbucket repository. Oddly enough, running npm install locally on my machine is successful, but it fails when executed on the server. An error message displays: npm ERR! Erro ...

update the data source of the material table inside the subscription

Seeking guidance for updating a MatTable datasource within an Angular application. The current Typescript code involves fetching data from an API using AdminService, iterating over the results to make additional API calls for more information about a fleet ...

How can JSON be best connected in Angular for optimal performance?

My JSON structure is as follows: { items:[], errors:[], foundItems:9 } One part of my program requires access to "items", while another part needs access to "errors." To resolve this issue, I decided to create a new interface and a new class to hand ...

Has anybody successfully implemented the danfojs-node package on an Apple M1 chip?

I encountered an issue when trying to use danfojs-node on a Mac with an M1 chip - it kept crashing due to TensorFlow. I'm curious if anyone has managed to successfully integrate the npm package from this link (https://www.npmjs.com/package/danfojs-nod ...

NPM fails to install dependencies requiring compilation

Here is how my package.json file appears: { "name": "anna-backend", "version": "1.0.3", "description": "Backend for ANNA intranet", "main": "app.js", "author": "IpsaOne DevTeam", "private": true, "license": "ISC", "dependencies": { "as ...

What causes Gun.js to generate duplicate messages within a ReactJs environment?

I need assistance with my React application where gun.js is implemented. The issue I am facing is that messages are being duplicated on every render and update. Can someone please review my code and help me figure out what's wrong? Here is the code s ...

Encountering an issue accessing a property retrieved from a fetch request in TypeScript

I am currently dealing with the property success defined in the API (reCAPTCHA). /** * The structure of response from the veirfy API is * { * "success": true|false, * "challenge_ts": timestamp, // timestamp of the challen ...

Why is Nuxt.js launching in a Linux virtual machine but not in a Docker container?

I've encountered varying results when launching a Nuxt app from the Windows subsystem for Linux versus starting the same app in Docker. While I have experience dockerizing other apps, this particular issue has me stumped. WSL Connections are being l ...

A guide to adjusting the font size and placement of text in a precise manner

Is there a way to adjust the font size and position in a particular text? How can this be achieved? doc.text( 40, 30, "jspdf" ); https://i.stack.imgur.com/Io7RE.png ...

What is the reason for Bower consistently choosing to download the Angular version 1.5.9-build.5086+sha...?

Struggling to manage my front end dependencies using bower.json. No matter how I specify the version of Angular in bower, a different version is downloaded every time. The issue is that many functionalities in my code rely on previous versions of Angular, ...

Is it possible to create a distinctive property value within an ngFor loop that operates autonomously across two child components?

I am working on a functionality where, upon clicking on a specific car brand, the name of the person and their favorite car will be displayed at the bottom. However, I'm facing an issue where the car brand is being repeated among all items in the ngFo ...

TS1057: It is required that an async function or method has a return type that can be awaited

There was a recent Github issue reported on March 28th regarding async arrow functions generating faulty code when targeting ES5, resulting in the error message: TS1057: An async function or method must have a valid awaitable return type You can find t ...

Can we find a solution to optimize this unique component and minimize redundant code?

Currently, I have a wrapper component that enhances the functionality of the MUI Tooltip component by automatically closing the tooltip when the surrounding table is scrolled. The existing code works fine, but I want to enhance its quality by removing du ...

Ways to update the value of an object in typescript

When working with an array of objects, I encountered an issue while trying to change the object value. The error message "Type 'string | boolean' is not assignable to type 'never'. Type 'string' is not assignable to type &apos ...

The choice between using "npm install" and "npm install -g" for

New to the world of node, and feeling a bit lost when it comes to all this "install" stuff. Could someone clarify for me, what sets apart install from install -g? If something is installed with install -g, can it be accessed from anywhere, or is it restr ...

Navigating to a specific section upon clicking

Imagine a scenario where there is a landing page with a button. When the button is clicked, redirection to another page with multiple components occurs. Each component on this new page serves a different function. Additionally, the desired functionality in ...

Ways to figure out the origin of an npm package installation location?

Is there a way to identify the source of installation for an npm package? We all know about using npm view <package> to check details from a registry, but what about packages installed from sources other than a registry (like a git repo or local dir ...