Replies: 2 comments 1 reply
|
update: I have made a npm lib where it logs the any feedback would be nice |
|
Interesting. I came here also curious about the mechanics. It seems the model: it's glob-driven, not a recursive pub fn get_package_jsons(
&self,
repo_root: &AbsoluteSystemPath,
) -> Result<impl Iterator<Item = AbsoluteSystemPathBuf> + use<>, Error> {
let globs = self.get_workspace_globs(repo_root)?;
Ok(globs.get_package_jsons(repo_root)?)
}And for pnpm specifically ( pub fn get_configured_workspace_globs(repo_root: &AbsoluteSystemPath) -> Option<Vec<String>> {
let pnpm_workspace = PnpmWorkspace::from_file(repo_root).ok()?;
// ...
Some(pnpm_workspace.packages)
}So the source of truth is For the edges, once each workspace's for dependency in internal {
let dependency_idx = self
.node_lookup
.get(&PackageNode::Workspace(dependency))
.expect("unable to find workspace node index");
self.workspace_graph.add_edge(*node_idx, *dependency_idx, ());
}This is just the package graph. The actual run-order DAG is probably composed on top using What is |
Uh oh!
There was an error while loading. Please reload this page.
Summary
Since Turborepo builds only the changed and affected packages, it needs a DAG (directed acyclic graph) that tracks package dependencies. While reading the implementation, I noticed that recursion stops when a package.json is found in a directory, so that folder becomes a node in the graph and traversal doesn’t go deeper.
I also noticed that the DAG generation part is implemented in Rust for performance reasons.
Is this understanding correct?
I’m curious whether the DAG builder walks through each directory, detects package.json, and reads its contents to build a node. If so, how is that traversal performed and how are the dependencies extracted?
Additional information
No response
Example
No response
All reactions