Skip to content

Commit 2da1956

Browse files
committed
Try legacy behaviour
1 parent 6b80dc1 commit 2da1956

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

rewatch/src/build/build_types.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,26 @@ impl BuildState {
106106
}
107107

108108
pub fn get_module(&self, module_name: &str) -> Option<&Module> {
109-
self.modules.get(module_name)
109+
// Try exact match first
110+
if let Some(module) = self.modules.get(module_name) {
111+
return Some(module);
112+
}
113+
// Fallback: try with first letter uncapitalized (legacy behavior)
114+
// This matches the logic in compiler/gentype/ModuleResolver.ml:
115+
// match map |> ModuleNameMap.find module_name with
116+
// | resolved_module_dir -> Some (resolved_module_dir, Uppercase, bs_dependencies)
117+
// | exception Not_found -> (
118+
// match map |> ModuleNameMap.find (module_name |> ModuleName.uncapitalize)
119+
// with | resolved_module_dir -> Some (resolved_module_dir, Lowercase, bs_dependencies)
120+
// | exception Not_found -> None)
121+
if let Some(first_char) = module_name.chars().next() {
122+
if first_char.is_ascii_uppercase() {
123+
let mut uncapitalized = first_char.to_lowercase().collect::<String>();
124+
uncapitalized.push_str(&module_name[1..]);
125+
return self.modules.get(&uncapitalized);
126+
}
127+
}
128+
None
110129
}
111130
pub fn new(
112131
project_root: PathBuf,

0 commit comments

Comments
 (0)