Skip to main content

chainsaw/
lib.rs

1//! Build and query dependency graphs for TypeScript/JavaScript and Python codebases.
2//!
3//! Chainsaw parses import statements, resolves them against the filesystem, and
4//! constructs a full transitive dependency graph from any entry file. The graph
5//! can then be queried for total import weight, heaviest packages, shortest
6//! import chains, optimal cut points, and before/after diffs.
7//!
8//! This library backs the `chainsaw` CLI. The public API is internal and
9//! unstable -- it exists so benchmarks and tests can access internals.
10
11#![warn(clippy::pedantic)]
12#![allow(clippy::must_use_candidate)]
13#![allow(clippy::missing_errors_doc)]
14#![allow(clippy::missing_panics_doc)]
15#![allow(clippy::module_name_repetitions)]
16// compact_str 0.8 (oxc_span) + 0.9 (oxc_resolver) — transitive, out of our control.
17#![allow(clippy::multiple_crate_versions)]
18
19pub mod cache;
20pub mod error;
21pub mod git;
22pub mod graph;
23pub mod lang;
24pub mod loader;
25pub mod query;
26pub mod report;
27pub mod walker;
28
29/// Compile-time guard: all public types must be Send + Sync + Unpin.
30/// If an internal change (e.g. adding Rc or Cell) breaks these, this
31/// test will fail to compile rather than silently degrading the API.
32#[cfg(test)]
33mod auto_trait_tests {
34    fn is_normal<T: Sized + Send + Sync + Unpin>() {}
35
36    #[test]
37    fn public_types_are_send_sync() {
38        is_normal::<crate::graph::ModuleId>();
39        is_normal::<crate::graph::EdgeId>();
40        is_normal::<crate::graph::EdgeKind>();
41        is_normal::<crate::graph::Module>();
42        is_normal::<crate::graph::Edge>();
43        is_normal::<crate::graph::ModuleGraph>();
44        is_normal::<crate::query::TraceResult>();
45        is_normal::<crate::query::TraceSnapshot>();
46        is_normal::<crate::query::DiffResult>();
47        is_normal::<crate::walker::BuildResult>();
48        is_normal::<crate::error::Error>();
49        is_normal::<crate::loader::LoadedGraph>();
50        is_normal::<crate::lang::ParseError>();
51        is_normal::<crate::lang::RawImport>();
52        is_normal::<crate::lang::ParseResult>();
53        is_normal::<crate::lang::ProjectKind>();
54        is_normal::<crate::git::DiffArg>();
55        is_normal::<crate::git::TempWorktree>();
56    }
57}