admin管理员组

文章数量:1125922

I'm trying to reduce incremental build time of tsc. In general when a file's "shape"(it's declaration file) is changed, tsc compiler will use "referenceMap" to find all files referencing it. And all of them will be checked.
Consider the following case:
If we modify a file, and just add a new export for it, even though no other file is using the exported element, we still need to check all files referencing it because it's shape is changed. But actually we can just check this file only. So, is it possible that we do incremental build more precisely, like: find the exported element that changed(or may be affected by our changes) and only check files that using this element in incremental build.

I found it was difficult though, and wondering why tsc didn't do that?

A more specific sample:
fileA.ts:

export class A {
  prop = 1;
}

fileB.ts:

import {A} from './fileA'
...(some code)
export {A};

fileC.ts:

import {A} from './fileB'
...(some code)

So, we have the referenceMap of "fileA->fileB->fileC". If we modified fileA.ts to:

export class A {
  prop = "1";
}

We definitely need to check fileA, fileB, and fileC because fileA's shape has been changed. But, if we only add an export element that no other file is using it:

export class A {
  prop = 1;
}
export let A1 = 1;

Tsc still need to check fileA, fileB, and fileC.
Is it possible that we do incremental build based on the relationship of symobols?
So that we can reduce the files that we need to check in incremental build. In the case above, since no other file is using 'A1', we only need to check fileA.

本文标签: