Skip to content

Commit

Permalink
Allow no sources in rescript.json - warn when not root package
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandpeelen committed Nov 18, 2024
1 parent b66376a commit 8dadf16
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/build/packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ fn flatten_dependencies(dependencies: Vec<Dependency>) -> Vec<Dependency> {

fn make_package(config: config::Config, package_path: &str, is_pinned_dep: bool, is_root: bool) -> Package {
let source_folders = match config.sources.to_owned() {
config::OneOrMore::Single(source) => get_source_dirs(source, None),
config::OneOrMore::Multiple(sources) => {
Some(config::OneOrMore::Single(source)) => get_source_dirs(source, None),
Some(config::OneOrMore::Multiple(sources)) => {
let mut source_folders: AHashSet<config::PackageSource> = AHashSet::new();
sources
.iter()
Expand All @@ -369,6 +369,13 @@ fn make_package(config: config::Config, package_path: &str, is_pinned_dep: bool,
.for_each(|source| source_folders.extend(source));
source_folders
}
None => {
if !is_root {
log::warn!("Package '{}' has not defined any sources, but is not the root package. This is likely a mistake. It is located: {}", config.name, package_path);
}

AHashSet::new()
}
};

Package {
Expand Down
4 changes: 3 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ pub type GenTypeConfig = serde_json::Value;
#[derive(Deserialize, Debug, Clone)]
pub struct Config {
pub name: String,
pub sources: OneOrMore<Source>,
// In the case of monorepos, the root source won't necessarily have to have sources. It can
// just be sources in packages
pub sources: Option<OneOrMore<Source>>,
#[serde(rename = "package-specs")]
pub package_specs: Option<OneOrMore<PackageSpec>>,
pub warnings: Option<Warnings>,
Expand Down

0 comments on commit 8dadf16

Please sign in to comment.