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 repl;
27pub mod report;
28pub mod session;
29pub mod vfs;
30pub mod walker;
31
32/// Compile-time guard: all public types must be Send + Sync + Unpin.
33/// If an internal change (e.g. adding Rc or Cell) breaks these, this
34/// test will fail to compile rather than silently degrading the API.
35#[cfg(test)]
36mod auto_trait_tests {
37    fn is_normal<T: Sized + Send + Sync + Unpin>() {}
38
39    #[test]
40    fn public_types_are_send_sync() {
41        is_normal::<crate::graph::ModuleId>();
42        is_normal::<crate::graph::EdgeId>();
43        is_normal::<crate::graph::EdgeKind>();
44        is_normal::<crate::graph::Module>();
45        is_normal::<crate::graph::Edge>();
46        is_normal::<crate::graph::ModuleGraph>();
47        is_normal::<crate::query::TraceResult>();
48        is_normal::<crate::query::TraceSnapshot>();
49        is_normal::<crate::query::DiffResult>();
50        is_normal::<crate::walker::BuildResult>();
51        is_normal::<crate::error::Error>();
52        is_normal::<crate::loader::LoadedGraph>();
53        is_normal::<crate::session::Session>();
54        is_normal::<crate::session::ResolvedTarget>();
55        is_normal::<crate::lang::ParseError>();
56        is_normal::<crate::lang::RawImport>();
57        is_normal::<crate::lang::ParseResult>();
58        is_normal::<crate::lang::ProjectKind>();
59        is_normal::<crate::git::DiffArg>();
60        is_normal::<crate::repl::Command>();
61        is_normal::<crate::repl::ReplSettings>();
62        is_normal::<crate::repl::CommandOptions>();
63        is_normal::<crate::report::TraceReport>();
64        is_normal::<crate::report::ChainReport>();
65        is_normal::<crate::report::CutReport>();
66        is_normal::<crate::report::DiffReport>();
67        is_normal::<crate::report::PackagesReport>();
68        is_normal::<crate::vfs::VfsMetadata>();
69        is_normal::<crate::vfs::OsVfs>();
70        is_normal::<crate::vfs::GitTreeVfs>();
71    }
72}