tsconfig_includes/
lib.rs

1//! Enumerate source code files used by the TypeScript compiler during
2//! compilation. The return value is a list of relative paths from the monorepo
3//! root, sorted in alphabetical order.
4//!
5//! There are two methods of calculating this list of files: the exact
6//! way, and using an estimation.
7//!
8//! The **exact** method uses the TypeScript compiler's [listFilesOnly] flag as the
9//! source of truth. We do not try to reimplement this algorithm independently
10//! because this list requires following `import` statements in JavaScript and
11//! TypeScript code. From the [tsconfig exclude] documentation:
12//!
13//! > Important: `exclude` *only* changes which files are included as a result
14//! > of the `include` setting. A file specified by exclude can still become
15//! > part of your codebase due to an import statement in your code, a types
16//! > inclusion, a `/// <reference` directive, or being specified in the
17//! > `files` list.
18//!
19//! The TypeScript compiler is a project where the implementation is the spec,
20//! so this method of enumeration trades the runtime penalty of invoking the
21//! TypeScript compiler for accuracy of output as defined by the "spec".
22//!
23//! The **estimation** method uses the list of globs from the `include`
24//! property in a package's tsconfig.json file to calculate the list of source
25//! files.
26//!
27//! This estimation is currently imprecise (and likely to stay that way) --
28//! it makes a best attempt to follow the `exclude` or file-type based rules:
29//!
30//! > If a glob pattern doesn’t include a file extension, then only files with
31//! > supported extensions are included (e.g. .ts, .tsx, and .d.ts by default,
32//! > with .js and .jsx if allowJs is set to true).
33//!
34//! without any guarantee of exhaustive compatibility.
35//!
36//! Additionally, this method performs no source-code analysis to follow
37//! imported files.
38//!
39//! You might want to use the estimation method if speed is a concern, because it
40//! is several orders of magnitude faster than the exact method.
41//!
42//! [listfilesonly]: https://www.typescriptlang.org/docs/handbook/compiler-options.html#compiler-options
43//! [tsconfig exclude]: https://www.typescriptlang.org/tsconfig#exclude
44
45#![forbid(unsafe_code)]
46#![deny(missing_debug_implementations)]
47
48pub mod estimate;
49pub mod exact;
50pub mod io;
51pub mod path;
52pub mod typescript_package;