17 stable releases (4 major)
5.0.3 | Sep 24, 2023 |
---|---|
5.0.2 | Sep 23, 2023 |
4.2.1 | Feb 10, 2023 |
3.2.0 | Feb 8, 2023 |
1.0.0 | Nov 13, 2022 |
#1328 in Command line utilities
68 downloads per month
42KB
951 lines
tsconfig-includes
tsconfig-includes enumerates files used in the TypeScript compilation
process for monorepo packages. While tsc --listFilesOnly
only lists input
files in the target package, tsconfig-includes lists input files in the
target package and all of its internal dependencies. You can use this list to
determine when inputs to a package has changed, to decide whether to rebuild
the package or used a cached version.
lib.rs
:
Enumerate source code files used by the TypeScript compiler during compilation. The return value is a list of relative paths from the monorepo root, sorted in alphabetical order.
There are two methods of calculating this list of files: the exact way, and using an estimation.
The exact method uses the TypeScript compiler's listFilesOnly flag as the
source of truth. We do not try to reimplement this algorithm independently
because this list requires following import
statements in JavaScript and
TypeScript code. From the tsconfig exclude documentation:
Important:
exclude
only changes which files are included as a result of theinclude
setting. A file specified by exclude can still become part of your codebase due to an import statement in your code, a types inclusion, a/// <reference
directive, or being specified in thefiles
list.
The TypeScript compiler is a project where the implementation is the spec, so this method of enumeration trades the runtime penalty of invoking the TypeScript compiler for accuracy of output as defined by the "spec".
The estimation method uses the list of globs from the include
property in a package's tsconfig.json file to calculate the list of source
files.
This estimation is currently imprecise (and likely to stay that way) --
it makes a best attempt to follow the exclude
or file-type based rules:
If a glob pattern doesn’t include a file extension, then only files with supported extensions are included (e.g. .ts, .tsx, and .d.ts by default, with .js and .jsx if allowJs is set to true).
without any guarantee of exhaustive compatibility.
Additionally, this method performs no source-code analysis to follow imported files.
You might want to use the estimation method if speed is a concern, because it is several orders of magnitude faster than the exact method.
Dependencies
~12–21MB
~225K SLoC