Skip to content

Commit b4feb96

Browse files
committed
🎨 - Allow no sources in rescript.json - warn when not root package
1 parent 651b086 commit b4feb96

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/build/packages.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,8 @@ fn flatten_dependencies(dependencies: Vec<Dependency>) -> Vec<Dependency> {
358358

359359
fn make_package(config: config::Config, package_path: &str, is_pinned_dep: bool, is_root: bool) -> Package {
360360
let source_folders = match config.sources.to_owned() {
361-
config::OneOrMore::Single(source) => get_source_dirs(source, None),
362-
config::OneOrMore::Multiple(sources) => {
361+
Some(config::OneOrMore::Single(source)) => get_source_dirs(source, None),
362+
Some(config::OneOrMore::Multiple(sources)) => {
363363
let mut source_folders: AHashSet<config::PackageSource> = AHashSet::new();
364364
sources
365365
.iter()
@@ -369,6 +369,13 @@ fn make_package(config: config::Config, package_path: &str, is_pinned_dep: bool,
369369
.for_each(|source| source_folders.extend(source));
370370
source_folders
371371
}
372+
None => {
373+
if !is_root {
374+
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);
375+
}
376+
377+
AHashSet::new()
378+
}
372379
};
373380

374381
Package {

src/config.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ pub type GenTypeConfig = serde_json::Value;
171171
#[derive(Deserialize, Debug, Clone)]
172172
pub struct Config {
173173
pub name: String,
174-
pub sources: OneOrMore<Source>,
174+
// In the case of monorepos, the root source won't necessarily have to have sources. It can
175+
// just be sources in packages
176+
pub sources: Option<OneOrMore<Source>>,
175177
#[serde(rename = "package-specs")]
176178
pub package_specs: Option<OneOrMore<PackageSpec>>,
177179
pub warnings: Option<Warnings>,

0 commit comments

Comments
 (0)