-
Notifications
You must be signed in to change notification settings - Fork 471
Fix sourcedirs.json generation #7671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a423415
94db6e8
9914c8b
ff43deb
a08f2dd
7a36c7e
9e1a059
4e4471d
f3eeb66
170c1a6
27f34bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,15 +21,16 @@ pub struct SourceDirs<'a> { | |
} | ||
|
||
fn package_to_dirs(package: &Package, root_package_path: &Path) -> AHashSet<Dir> { | ||
let relative_path = package.path.strip_prefix(root_package_path).unwrap(); | ||
|
||
package | ||
.dirs | ||
.as_ref() | ||
.unwrap_or(&AHashSet::new()) | ||
.iter() | ||
.map(|path| relative_path.join(path)) | ||
.collect::<AHashSet<PathBuf>>() | ||
match package.path.strip_prefix(root_package_path) { | ||
Err(_) => AHashSet::new(), | ||
Ok(relative_path) => package | ||
.dirs | ||
.as_ref() | ||
.unwrap_or(&AHashSet::new()) | ||
.iter() | ||
.map(|path| relative_path.join(path)) | ||
.collect::<AHashSet<PathBuf>>(), | ||
} | ||
} | ||
|
||
fn deps_to_pkgs<'a>( | ||
|
@@ -61,11 +62,13 @@ pub fn print(buildstate: &BuildState) { | |
.find(|(_name, package)| package.is_root) | ||
.expect("Could not find root package"); | ||
|
||
// Take all packages apart from the root package | ||
// Take all local packages with source files. | ||
// In the case of a monorepo, the root package typically won't have any source files. | ||
// But in the case of a single package, it will be both local, root and have source files. | ||
let (dirs, pkgs): (Vec<AHashSet<Dir>>, Vec<AHashMap<PackageName, AbsolutePath>>) = buildstate | ||
.packages | ||
.par_iter() | ||
.filter(|(_name, package)| !package.is_root) | ||
.filter(|(_name, package)| package.is_local_dep && package.source_files.is_some()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case there is only a single rescript.json, this will also ensure it gets processed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The goal here is to find all packages except for the root package, why is this behavior changing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh the root is never a local dep, and we don't want to have any other deps? Maybe you should update the comment if people run into this code later? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
.map(|(_name, package)| { | ||
// Extract Directories | ||
let dirs = package_to_dirs(package, &root_package.path); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a simpler fix for the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!