From 058f6a14a604c929b62023e69c4d87b79a423d16 Mon Sep 17 00:00:00 2001 From: tsnobip Date: Wed, 23 Jul 2025 11:29:29 +0200 Subject: [PATCH 01/13] add file-casing test repo to rewatch tests --- rewatch/testrepo/package.json | 3 ++- rewatch/testrepo/packages/file-casing/rescript.json | 1 + rewatch/testrepo/packages/file-casing/src/Consume.mjs | 4 ++-- rewatch/testrepo/rescript.json | 3 ++- rewatch/testrepo/yarn.lock | 6 ++++++ .../snapshots/bs-dev-dependency-used-by-non-dev-source.txt | 3 ++- rewatch/tests/snapshots/dependency-cycle.txt | 3 ++- rewatch/tests/snapshots/remove-file.txt | 3 ++- .../tests/snapshots/rename-file-internal-dep-namespace.txt | 3 ++- rewatch/tests/snapshots/rename-file-internal-dep.txt | 3 ++- rewatch/tests/snapshots/rename-file-with-interface.txt | 3 ++- rewatch/tests/snapshots/rename-interface-file.txt | 3 ++- 12 files changed, 27 insertions(+), 11 deletions(-) diff --git a/rewatch/testrepo/package.json b/rewatch/testrepo/package.json index 34f0d22239..5c0e8f9ed2 100644 --- a/rewatch/testrepo/package.json +++ b/rewatch/testrepo/package.json @@ -11,7 +11,8 @@ "packages/with-dev-deps", "packages/compiled-by-legacy", "packages/nonexisting-dev-files", - "packages/deprecated-config" + "packages/deprecated-config", + "packages/file-casing" ] }, "dependencies": { diff --git a/rewatch/testrepo/packages/file-casing/rescript.json b/rewatch/testrepo/packages/file-casing/rescript.json index 50914c1025..39a3626510 100644 --- a/rewatch/testrepo/packages/file-casing/rescript.json +++ b/rewatch/testrepo/packages/file-casing/rescript.json @@ -1,5 +1,6 @@ { "name": "@testrepo/file-casing", + "namespace": "FileCasing", "sources": [ { "dir": "src", diff --git a/rewatch/testrepo/packages/file-casing/src/Consume.mjs b/rewatch/testrepo/packages/file-casing/src/Consume.mjs index 68f3c4874b..0603a732aa 100644 --- a/rewatch/testrepo/packages/file-casing/src/Consume.mjs +++ b/rewatch/testrepo/packages/file-casing/src/Consume.mjs @@ -1,8 +1,8 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Produce$NamespaceCasingAPI from "./produce.mjs"; +import * as Produce$FileCasing from "./produce.mjs"; -let x = Produce$NamespaceCasingAPI.meh(1); +let x = Produce$FileCasing.meh(1); export { x, diff --git a/rewatch/testrepo/rescript.json b/rewatch/testrepo/rescript.json index 008a339de5..21b8ae5f55 100644 --- a/rewatch/testrepo/rescript.json +++ b/rewatch/testrepo/rescript.json @@ -23,6 +23,7 @@ "@testrepo/with-dev-deps", "@testrepo/compiled-by-legacy", "@testrepo/nonexisting-dev-files", - "@testrepo/deprecated-config" + "@testrepo/deprecated-config", + "@testrepo/file-casing" ] } diff --git a/rewatch/testrepo/yarn.lock b/rewatch/testrepo/yarn.lock index 8317e98114..b142544a64 100644 --- a/rewatch/testrepo/yarn.lock +++ b/rewatch/testrepo/yarn.lock @@ -75,6 +75,12 @@ __metadata: languageName: unknown linkType: soft +"@testrepo/file-casing@workspace:packages/file-casing": + version: 0.0.0-use.local + resolution: "@testrepo/file-casing@workspace:packages/file-casing" + languageName: unknown + linkType: soft + "@testrepo/main@workspace:packages/main": version: 0.0.0-use.local resolution: "@testrepo/main@workspace:packages/main" diff --git a/rewatch/tests/snapshots/bs-dev-dependency-used-by-non-dev-source.txt b/rewatch/tests/snapshots/bs-dev-dependency-used-by-non-dev-source.txt index 612ef06fad..adb3c71ffe 100644 --- a/rewatch/tests/snapshots/bs-dev-dependency-used-by-non-dev-source.txt +++ b/rewatch/tests/snapshots/bs-dev-dependency-used-by-non-dev-source.txt @@ -25,4 +25,5 @@ Use 'compiler-flags' instead. -Incremental build failed. Error:  Failed to Compile. See Errors Above +Incremental build failed. Error:  + Failed to Compile. See Errors Above diff --git a/rewatch/tests/snapshots/dependency-cycle.txt b/rewatch/tests/snapshots/dependency-cycle.txt index fc917ef90a..531beeca10 100644 --- a/rewatch/tests/snapshots/dependency-cycle.txt +++ b/rewatch/tests/snapshots/dependency-cycle.txt @@ -18,4 +18,5 @@ Dep01 → NewNamespace.NS_alias → Dep01 -Incremental build failed. Error:  Failed to Compile. See Errors Above +Incremental build failed. Error:  + Failed to Compile. See Errors Above diff --git a/rewatch/tests/snapshots/remove-file.txt b/rewatch/tests/snapshots/remove-file.txt index 44af3f1f88..c246876151 100644 --- a/rewatch/tests/snapshots/remove-file.txt +++ b/rewatch/tests/snapshots/remove-file.txt @@ -27,4 +27,5 @@ Use 'compiler-flags' instead. -Incremental build failed. Error:  Failed to Compile. See Errors Above +Incremental build failed. Error:  + Failed to Compile. See Errors Above diff --git a/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt b/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt index 081e01497b..20ecae99e9 100644 --- a/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt +++ b/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt @@ -27,4 +27,5 @@ Use 'compiler-flags' instead. Hint: Did you mean Other_module2? -Incremental build failed. Error:  Failed to Compile. See Errors Above +Incremental build failed. Error:  + Failed to Compile. See Errors Above diff --git a/rewatch/tests/snapshots/rename-file-internal-dep.txt b/rewatch/tests/snapshots/rename-file-internal-dep.txt index fb5ccbd7b3..cea2bd8385 100644 --- a/rewatch/tests/snapshots/rename-file-internal-dep.txt +++ b/rewatch/tests/snapshots/rename-file-internal-dep.txt @@ -27,4 +27,5 @@ Use 'compiler-flags' instead. -Incremental build failed. Error:  Failed to Compile. See Errors Above +Incremental build failed. Error:  + Failed to Compile. See Errors Above diff --git a/rewatch/tests/snapshots/rename-file-with-interface.txt b/rewatch/tests/snapshots/rename-file-with-interface.txt index 002228c2af..f5cce9e651 100644 --- a/rewatch/tests/snapshots/rename-file-with-interface.txt +++ b/rewatch/tests/snapshots/rename-file-with-interface.txt @@ -1,4 +1,5 @@ - No implementation file found for interface file (skipping): src/ModuleWithInterface.resi + + No implementation file found for interface file (skipping): src/ModuleWithInterface.resi Cleaned 2/56 Parsed 1 source files Compiled 2 modules diff --git a/rewatch/tests/snapshots/rename-interface-file.txt b/rewatch/tests/snapshots/rename-interface-file.txt index a0da89ae4b..ef4b99a335 100644 --- a/rewatch/tests/snapshots/rename-interface-file.txt +++ b/rewatch/tests/snapshots/rename-interface-file.txt @@ -1,4 +1,5 @@ - No implementation file found for interface file (skipping): src/ModuleWithInterface2.resi + + No implementation file found for interface file (skipping): src/ModuleWithInterface2.resi Cleaned 1/56 Parsed 1 source files Compiled 2 modules From 6ee8d2c39448dc9a364e7e0a5960026bf7950899 Mon Sep 17 00:00:00 2001 From: nojaf Date: Thu, 24 Jul 2025 13:18:03 +0200 Subject: [PATCH 02/13] Update expected files --- rewatch/tests/format.sh | 2 +- rewatch/tests/suffix.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rewatch/tests/format.sh b/rewatch/tests/format.sh index 6520a33a42..cc6d72fc94 100755 --- a/rewatch/tests/format.sh +++ b/rewatch/tests/format.sh @@ -6,7 +6,7 @@ bold "Test: It should format all files" git diff --name-only ./ error_output=$("$REWATCH_EXECUTABLE" format --all) git_diff_file_count=$(git diff --name-only ./ | wc -l | xargs) -if [ $? -eq 0 ] && [ $git_diff_file_count -eq 4 ]; +if [ $? -eq 0 ] && [ $git_diff_file_count -eq 6 ]; then success "Test package formatted. Got $git_diff_file_count changed files." git restore . diff --git a/rewatch/tests/suffix.sh b/rewatch/tests/suffix.sh index 4586fcb05a..a7d6ed8f83 100755 --- a/rewatch/tests/suffix.sh +++ b/rewatch/tests/suffix.sh @@ -31,7 +31,7 @@ fi # Count files with new extension file_count=$(find ./packages -name *.res.js | wc -l) -if [ "$file_count" -eq 28 ]; +if [ "$file_count" -eq 32 ]; then success "Found files with correct suffix" else From 3aadd809856185439ff5e7eff6c8cb5cb9d16f2a Mon Sep 17 00:00:00 2001 From: nojaf Date: Thu, 24 Jul 2025 14:34:25 +0200 Subject: [PATCH 03/13] Try legacy behaviour --- rewatch/src/build/build_types.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/rewatch/src/build/build_types.rs b/rewatch/src/build/build_types.rs index e8c1a28ee4..4a705cae28 100644 --- a/rewatch/src/build/build_types.rs +++ b/rewatch/src/build/build_types.rs @@ -106,7 +106,26 @@ impl BuildState { } pub fn get_module(&self, module_name: &str) -> Option<&Module> { - self.modules.get(module_name) + // Try exact match first + if let Some(module) = self.modules.get(module_name) { + return Some(module); + } + // Fallback: try with first letter uncapitalized (legacy behavior) + // This matches the logic in compiler/gentype/ModuleResolver.ml: + // match map |> ModuleNameMap.find module_name with + // | resolved_module_dir -> Some (resolved_module_dir, Uppercase, bs_dependencies) + // | exception Not_found -> ( + // match map |> ModuleNameMap.find (module_name |> ModuleName.uncapitalize) + // with | resolved_module_dir -> Some (resolved_module_dir, Lowercase, bs_dependencies) + // | exception Not_found -> None) + if let Some(first_char) = module_name.chars().next() { + if first_char.is_ascii_uppercase() { + let mut uncapitalized = first_char.to_lowercase().collect::(); + uncapitalized.push_str(&module_name[1..]); + return self.modules.get(&uncapitalized); + } + } + None } pub fn new( project_root: PathBuf, From 0c0826abff10d5a031c4860279b8ec5740bcc29b Mon Sep 17 00:00:00 2001 From: nojaf Date: Thu, 24 Jul 2025 14:39:02 +0200 Subject: [PATCH 04/13] Revert "Try legacy behaviour" This reverts commit 2da1956acc459789ee4bd83132c58f51aac04cfa. --- rewatch/src/build/build_types.rs | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/rewatch/src/build/build_types.rs b/rewatch/src/build/build_types.rs index 4a705cae28..e8c1a28ee4 100644 --- a/rewatch/src/build/build_types.rs +++ b/rewatch/src/build/build_types.rs @@ -106,26 +106,7 @@ impl BuildState { } pub fn get_module(&self, module_name: &str) -> Option<&Module> { - // Try exact match first - if let Some(module) = self.modules.get(module_name) { - return Some(module); - } - // Fallback: try with first letter uncapitalized (legacy behavior) - // This matches the logic in compiler/gentype/ModuleResolver.ml: - // match map |> ModuleNameMap.find module_name with - // | resolved_module_dir -> Some (resolved_module_dir, Uppercase, bs_dependencies) - // | exception Not_found -> ( - // match map |> ModuleNameMap.find (module_name |> ModuleName.uncapitalize) - // with | resolved_module_dir -> Some (resolved_module_dir, Lowercase, bs_dependencies) - // | exception Not_found -> None) - if let Some(first_char) = module_name.chars().next() { - if first_char.is_ascii_uppercase() { - let mut uncapitalized = first_char.to_lowercase().collect::(); - uncapitalized.push_str(&module_name[1..]); - return self.modules.get(&uncapitalized); - } - } - None + self.modules.get(module_name) } pub fn new( project_root: PathBuf, From ddd3fb372ed6144d4ac81e27f43d6c91b1a074a5 Mon Sep 17 00:00:00 2001 From: tsnobip Date: Thu, 24 Jul 2025 18:11:24 +0200 Subject: [PATCH 05/13] fix dev container --- .devcontainer/.dockerignore | 99 +++++++++++++++++++++++++++++++++ .devcontainer/Dockerfile | 10 +++- .devcontainer/devcontainer.json | 10 +++- .devcontainer/postCreate.sh | 10 ++-- 4 files changed, 118 insertions(+), 11 deletions(-) create mode 100644 .devcontainer/.dockerignore diff --git a/.devcontainer/.dockerignore b/.devcontainer/.dockerignore new file mode 100644 index 0000000000..cfecf53afa --- /dev/null +++ b/.devcontainer/.dockerignore @@ -0,0 +1,99 @@ +*~ +_build +*.obj +*.out +*.compile +*.native +*.byte +*.cmo +*.annot +*.cmi +*.cmx +*.cmt +*.cmti +*.cma +*.a +*.cmxa +*.obj + *~ +*.annot +*.mj +*.bak +*.swp +*.swo +*.flambda +*.jsx +*.lambda +*.rawlambda +*.s +*.o +*.lam +*.0.js +*# +*.log +.#* +*.cmj +*.rawlambda +*.lambda +*.zip +*.mlast +*.mliast + +.idea +.DS_Store + +node_modules +*.dump +coverage + +.ninja_log +.bsdeps +.bsbuild +lib/ocaml +tests/build_tests/*/lib/ +#ignore temporary directory +*.goog.js +*.jsoo.js +*.so +tmp/ +tracing*.json + +_opam + +.env +playground/packages/ +playground/stdlib/ +playground/*.cmj +playground/*.cmi +playground/.netrc +playground/compiler.*js + +rewatch/target/ +rewatch/rewatch + +tests/tools_tests/**/*.res.js +tests/tools_tests/lib +tests/analysis_tests*/lib +tests/analysis_tests/**/*.bs.js + +/linux/*.exe +/linuxarm64/*.exe +/darwin/*.exe +/darwinarm64/*.exe +/win32/*.exe + +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions + +*.tsbuildinfo + +# package tarballs +package.tgz +*.exe + +/ninja/ninja +/ninja/build.ninja \ No newline at end of file diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 90768e7639..f6906258a3 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -2,10 +2,14 @@ FROM mcr.microsoft.com/devcontainers/rust:1-1-bookworm LABEL org.opencontainers.image.authors="Christoph Knittel " LABEL org.opencontainers.image.description="Docker image for ReScript development." -RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +RUN sudo apt-get update && export DEBIAN_FRONTEND=noninteractive \ && apt-get -y install --no-install-recommends \ - yarn \ - opam \ + cmake \ + ninja-build \ musl-tools \ python-is-python3 \ && rm -rf /var/lib/apt/lists/* + +# Install OPAM +ARG OPAM_VERSION=2.4.1 +RUN printf '\n\n' | bash -c "sh <(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh) --version $OPAM_VERSION" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d03f934de1..d95de65de4 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,7 +2,11 @@ "name": "ReScript Compiler", "build": { "context": ".", - "dockerfile": "Dockerfile" + "dockerfile": "Dockerfile", + "args": { + "USER_UID": "${localEnv:UID}", + "USER_GID": "${localEnv:GID}" + } }, "features": { "ghcr.io/devcontainers/features/github-cli:1": { @@ -23,5 +27,7 @@ ] } }, - "postCreateCommand": ".devcontainer/postCreate.sh" + "postCreateCommand": ".devcontainer/postCreate.sh", + "remoteUser": "vscode", + "containerUser": "vscode" } diff --git a/.devcontainer/postCreate.sh b/.devcontainer/postCreate.sh index 79db8cc4f0..29e2493051 100755 --- a/.devcontainer/postCreate.sh +++ b/.devcontainer/postCreate.sh @@ -2,14 +2,12 @@ # Install dev dependencies from OPAM opam init -y --bare --disable-sandboxing -opam switch create 5.3.0 --packages ocaml-option-static -opam install . --deps-only -y - -# For IDE support, install the OCaml language server -opam install ocaml-lsp-server -y +opam switch create 5.3.0 +opam install . --deps-only --with-test --with-dev-setup -y # Add OPAM environment setup to shell startup script echo 'eval $(opam env)' >> ~/.zshrc echo 'eval $(opam env)' >> ~/.bashrc -npm install --ignore-scripts +corepack enable +printf "\n" | yarn From 3a8dfdf0610a302342f3ff2b6181134f1fd5469f Mon Sep 17 00:00:00 2001 From: tsnobip Date: Fri, 25 Jul 2025 10:45:00 +0200 Subject: [PATCH 06/13] use the right version of nodejs in dev container --- .devcontainer/postCreate.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.devcontainer/postCreate.sh b/.devcontainer/postCreate.sh index 29e2493051..c8288d1c83 100755 --- a/.devcontainer/postCreate.sh +++ b/.devcontainer/postCreate.sh @@ -9,5 +9,7 @@ opam install . --deps-only --with-test --with-dev-setup -y echo 'eval $(opam env)' >> ~/.zshrc echo 'eval $(opam env)' >> ~/.bashrc +nvm install + corepack enable printf "\n" | yarn From 5eb8580caa3552255e9f6f55dcc9b2030194da29 Mon Sep 17 00:00:00 2001 From: tsnobip Date: Wed, 30 Jul 2025 08:10:54 +0000 Subject: [PATCH 07/13] add a test repo for lowercase file with no namespace --- rewatch/testrepo/package.json | 3 ++- .../file-casing-no-namespace/package.json | 9 ++++++++ .../file-casing-no-namespace/rescript.json | 21 +++++++++++++++++++ .../file-casing-no-namespace/src/Consume.mjs | 10 +++++++++ .../file-casing-no-namespace/src/Consume.res | 1 + .../file-casing-no-namespace/src/produce.mjs | 11 ++++++++++ .../file-casing-no-namespace/src/produce.res | 3 +++ rewatch/testrepo/rescript.json | 3 ++- rewatch/testrepo/yarn.lock | 6 ++++++ 9 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 rewatch/testrepo/packages/file-casing-no-namespace/package.json create mode 100644 rewatch/testrepo/packages/file-casing-no-namespace/rescript.json create mode 100644 rewatch/testrepo/packages/file-casing-no-namespace/src/Consume.mjs create mode 100644 rewatch/testrepo/packages/file-casing-no-namespace/src/Consume.res create mode 100644 rewatch/testrepo/packages/file-casing-no-namespace/src/produce.mjs create mode 100644 rewatch/testrepo/packages/file-casing-no-namespace/src/produce.res diff --git a/rewatch/testrepo/package.json b/rewatch/testrepo/package.json index 5c0e8f9ed2..f42be392d8 100644 --- a/rewatch/testrepo/package.json +++ b/rewatch/testrepo/package.json @@ -12,7 +12,8 @@ "packages/compiled-by-legacy", "packages/nonexisting-dev-files", "packages/deprecated-config", - "packages/file-casing" + "packages/file-casing", + "packages/file-casing-no-namespace" ] }, "dependencies": { diff --git a/rewatch/testrepo/packages/file-casing-no-namespace/package.json b/rewatch/testrepo/packages/file-casing-no-namespace/package.json new file mode 100644 index 0000000000..97925cdac6 --- /dev/null +++ b/rewatch/testrepo/packages/file-casing-no-namespace/package.json @@ -0,0 +1,9 @@ +{ + "name": "@testrepo/file-casing-no-namespace", + "version": "0.0.1", + "keywords": [ + "rescript" + ], + "author": "", + "license": "MIT" +} diff --git a/rewatch/testrepo/packages/file-casing-no-namespace/rescript.json b/rewatch/testrepo/packages/file-casing-no-namespace/rescript.json new file mode 100644 index 0000000000..d1d6797059 --- /dev/null +++ b/rewatch/testrepo/packages/file-casing-no-namespace/rescript.json @@ -0,0 +1,21 @@ +{ + "name": "@testrepo/file-casing-no-namespace", + "sources": [ + { + "dir": "src", + "subdirs": true + } + ], + "package-specs": [ + { + "module": "es6", + "in-source": true + } + ], + "suffix": ".mjs", + "dependencies": [], + "compiler-flags": [], + "jsx": { + "version": 4 + } +} diff --git a/rewatch/testrepo/packages/file-casing-no-namespace/src/Consume.mjs b/rewatch/testrepo/packages/file-casing-no-namespace/src/Consume.mjs new file mode 100644 index 0000000000..9f00487db9 --- /dev/null +++ b/rewatch/testrepo/packages/file-casing-no-namespace/src/Consume.mjs @@ -0,0 +1,10 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Produce from "./produce.mjs"; + +let x = Produce.meh(1); + +export { + x, +} +/* x Not a pure module */ diff --git a/rewatch/testrepo/packages/file-casing-no-namespace/src/Consume.res b/rewatch/testrepo/packages/file-casing-no-namespace/src/Consume.res new file mode 100644 index 0000000000..e2d9a26460 --- /dev/null +++ b/rewatch/testrepo/packages/file-casing-no-namespace/src/Consume.res @@ -0,0 +1 @@ +let x = Produce.meh(1) \ No newline at end of file diff --git a/rewatch/testrepo/packages/file-casing-no-namespace/src/produce.mjs b/rewatch/testrepo/packages/file-casing-no-namespace/src/produce.mjs new file mode 100644 index 0000000000..2dc987f1bd --- /dev/null +++ b/rewatch/testrepo/packages/file-casing-no-namespace/src/produce.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function meh(param) { + return true; +} + +export { + meh, +} +/* No side effect */ diff --git a/rewatch/testrepo/packages/file-casing-no-namespace/src/produce.res b/rewatch/testrepo/packages/file-casing-no-namespace/src/produce.res new file mode 100644 index 0000000000..194a02d465 --- /dev/null +++ b/rewatch/testrepo/packages/file-casing-no-namespace/src/produce.res @@ -0,0 +1,3 @@ +let meh = (_: int) => { + true +} \ No newline at end of file diff --git a/rewatch/testrepo/rescript.json b/rewatch/testrepo/rescript.json index 21b8ae5f55..ae437e38dd 100644 --- a/rewatch/testrepo/rescript.json +++ b/rewatch/testrepo/rescript.json @@ -24,6 +24,7 @@ "@testrepo/compiled-by-legacy", "@testrepo/nonexisting-dev-files", "@testrepo/deprecated-config", - "@testrepo/file-casing" + "@testrepo/file-casing", + "@testrepo/file-casing-no-namespace" ] } diff --git a/rewatch/testrepo/yarn.lock b/rewatch/testrepo/yarn.lock index b142544a64..808197041f 100644 --- a/rewatch/testrepo/yarn.lock +++ b/rewatch/testrepo/yarn.lock @@ -75,6 +75,12 @@ __metadata: languageName: unknown linkType: soft +"@testrepo/file-casing-no-namespace@workspace:packages/file-casing-no-namespace": + version: 0.0.0-use.local + resolution: "@testrepo/file-casing-no-namespace@workspace:packages/file-casing-no-namespace" + languageName: unknown + linkType: soft + "@testrepo/file-casing@workspace:packages/file-casing": version: 0.0.0-use.local resolution: "@testrepo/file-casing@workspace:packages/file-casing" From de3da7402180e80533acbc57603ca3ebc26964ea Mon Sep 17 00:00:00 2001 From: tsnobip Date: Wed, 30 Jul 2025 08:12:46 +0000 Subject: [PATCH 08/13] fix compilation of files starting with lowercase letter --- rewatch/src/build/compile.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/rewatch/src/build/compile.rs b/rewatch/src/build/compile.rs index e5816347c8..443125fb1a 100644 --- a/rewatch/src/build/compile.rs +++ b/rewatch/src/build/compile.rs @@ -578,7 +578,7 @@ fn compile_file( ast_path.to_string_lossy() )), }?; - let module_name = helpers::file_path_to_module_name(implementation_file_path, &package.namespace); + let basename = helpers::file_path_to_compiler_asset_basename(implementation_file_path, &package.namespace); let has_interface = module.get_interface().is_some(); let is_type_dev = module.is_type_dev; let to_mjs_args = compiler_args( @@ -631,16 +631,17 @@ fn compile_file( // because editor tooling doesn't support namespace entries yet // we just remove the @ for now. This makes sure the editor support // doesn't break - .join(format!("{module_name}.cmi")), - ocaml_build_path_abs.join(format!("{module_name}.cmi")), + .join(format!("{basename}.cmi")), + ocaml_build_path_abs.join(format!("{basename}.cmi")), ); let _ = std::fs::copy( package .get_build_path() .join(dir) - .join(format!("{module_name}.cmj")), - ocaml_build_path_abs.join(format!("{module_name}.cmj")), + .join(format!("{basename}.cmj")), + ocaml_build_path_abs.join(format!("{basename}.cmj")), ); + println!("[rewatch] Copying file {basename} to ocaml build path"); let _ = std::fs::copy( package .get_build_path() @@ -648,23 +649,23 @@ fn compile_file( // because editor tooling doesn't support namespace entries yet // we just remove the @ for now. This makes sure the editor support // doesn't break - .join(format!("{module_name}.cmt")), - ocaml_build_path_abs.join(format!("{module_name}.cmt")), + .join(format!("{basename}.cmt")), + ocaml_build_path_abs.join(format!("{basename}.cmt")), ); } else { let _ = std::fs::copy( package .get_build_path() .join(dir) - .join(format!("{module_name}.cmti")), - ocaml_build_path_abs.join(format!("{module_name}.cmti")), + .join(format!("{basename}.cmti")), + ocaml_build_path_abs.join(format!("{basename}.cmti")), ); let _ = std::fs::copy( package .get_build_path() .join(dir) - .join(format!("{module_name}.cmi")), - ocaml_build_path_abs.join(format!("{module_name}.cmi")), + .join(format!("{basename}.cmi")), + ocaml_build_path_abs.join(format!("{basename}.cmi")), ); } From 7efca9ccfe63cede9163df34410d05b70db23bf8 Mon Sep 17 00:00:00 2001 From: tsnobip Date: Wed, 30 Jul 2025 08:18:08 +0000 Subject: [PATCH 09/13] format rust --- rewatch/src/build/compile.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/rewatch/src/build/compile.rs b/rewatch/src/build/compile.rs index 443125fb1a..38d623f13e 100644 --- a/rewatch/src/build/compile.rs +++ b/rewatch/src/build/compile.rs @@ -578,7 +578,8 @@ fn compile_file( ast_path.to_string_lossy() )), }?; - let basename = helpers::file_path_to_compiler_asset_basename(implementation_file_path, &package.namespace); + let basename = + helpers::file_path_to_compiler_asset_basename(implementation_file_path, &package.namespace); let has_interface = module.get_interface().is_some(); let is_type_dev = module.is_type_dev; let to_mjs_args = compiler_args( @@ -635,10 +636,7 @@ fn compile_file( ocaml_build_path_abs.join(format!("{basename}.cmi")), ); let _ = std::fs::copy( - package - .get_build_path() - .join(dir) - .join(format!("{basename}.cmj")), + package.get_build_path().join(dir).join(format!("{basename}.cmj")), ocaml_build_path_abs.join(format!("{basename}.cmj")), ); println!("[rewatch] Copying file {basename} to ocaml build path"); @@ -661,10 +659,7 @@ fn compile_file( ocaml_build_path_abs.join(format!("{basename}.cmti")), ); let _ = std::fs::copy( - package - .get_build_path() - .join(dir) - .join(format!("{basename}.cmi")), + package.get_build_path().join(dir).join(format!("{basename}.cmi")), ocaml_build_path_abs.join(format!("{basename}.cmi")), ); } From 92335692a0ef32754462d792fcbc7b90b4c48d9d Mon Sep 17 00:00:00 2001 From: tsnobip Date: Wed, 30 Jul 2025 08:19:07 +0000 Subject: [PATCH 10/13] update snapshots --- .../snapshots/bs-dev-dependency-used-by-non-dev-source.txt | 6 +++--- rewatch/tests/snapshots/dependency-cycle.txt | 5 ++--- rewatch/tests/snapshots/remove-file.txt | 5 ++--- .../tests/snapshots/rename-file-internal-dep-namespace.txt | 7 ++++--- rewatch/tests/snapshots/rename-file-internal-dep.txt | 6 +++--- rewatch/tests/snapshots/rename-file-with-interface.txt | 7 ++++--- rewatch/tests/snapshots/rename-file.txt | 3 ++- rewatch/tests/snapshots/rename-interface-file.txt | 7 ++++--- 8 files changed, 24 insertions(+), 22 deletions(-) diff --git a/rewatch/tests/snapshots/bs-dev-dependency-used-by-non-dev-source.txt b/rewatch/tests/snapshots/bs-dev-dependency-used-by-non-dev-source.txt index adb3c71ffe..9df0205a5d 100644 --- a/rewatch/tests/snapshots/bs-dev-dependency-used-by-non-dev-source.txt +++ b/rewatch/tests/snapshots/bs-dev-dependency-used-by-non-dev-source.txt @@ -1,5 +1,6 @@ -Cleaned 0/56 +Cleaned 0/60 Parsed 2 source files +[rewatch] Copying file NS_alias-@NewNamespace to ocaml build path Compiled 2 modules The field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config' is deprecated and will be removed in a future version. @@ -25,5 +26,4 @@ Use 'compiler-flags' instead. -Incremental build failed. Error:  - Failed to Compile. See Errors Above +Incremental build failed. Error:  Failed to Compile. See Errors Above diff --git a/rewatch/tests/snapshots/dependency-cycle.txt b/rewatch/tests/snapshots/dependency-cycle.txt index 531beeca10..cc25fb9c92 100644 --- a/rewatch/tests/snapshots/dependency-cycle.txt +++ b/rewatch/tests/snapshots/dependency-cycle.txt @@ -1,4 +1,4 @@ -Cleaned 0/56 +Cleaned 0/60 Parsed 1 source files Compiled 0 modules @@ -18,5 +18,4 @@ Dep01 → NewNamespace.NS_alias → Dep01 -Incremental build failed. Error:  - Failed to Compile. See Errors Above +Incremental build failed. Error:  Failed to Compile. See Errors Above diff --git a/rewatch/tests/snapshots/remove-file.txt b/rewatch/tests/snapshots/remove-file.txt index c246876151..a19c44e596 100644 --- a/rewatch/tests/snapshots/remove-file.txt +++ b/rewatch/tests/snapshots/remove-file.txt @@ -1,4 +1,4 @@ -Cleaned 1/56 +Cleaned 1/60 Parsed 0 source files Compiled 1 modules @@ -27,5 +27,4 @@ Use 'compiler-flags' instead. -Incremental build failed. Error:  - Failed to Compile. See Errors Above +Incremental build failed. Error:  Failed to Compile. See Errors Above diff --git a/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt b/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt index 20ecae99e9..d42004a89d 100644 --- a/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt +++ b/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt @@ -1,5 +1,7 @@ -Cleaned 2/56 +Cleaned 2/60 Parsed 2 source files +[rewatch] Copying file InternalDep to ocaml build path +[rewatch] Copying file Other_module2-@NewNamespace to ocaml build path Compiled 3 modules The field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config' is deprecated and will be removed in a future version. @@ -27,5 +29,4 @@ Use 'compiler-flags' instead. Hint: Did you mean Other_module2? -Incremental build failed. Error:  - Failed to Compile. See Errors Above +Incremental build failed. Error:  Failed to Compile. See Errors Above diff --git a/rewatch/tests/snapshots/rename-file-internal-dep.txt b/rewatch/tests/snapshots/rename-file-internal-dep.txt index cea2bd8385..d74a045181 100644 --- a/rewatch/tests/snapshots/rename-file-internal-dep.txt +++ b/rewatch/tests/snapshots/rename-file-internal-dep.txt @@ -1,5 +1,6 @@ -Cleaned 2/56 +Cleaned 2/60 Parsed 2 source files +[rewatch] Copying file InternalDep2 to ocaml build path Compiled 2 modules The field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config' is deprecated and will be removed in a future version. @@ -27,5 +28,4 @@ Use 'compiler-flags' instead. -Incremental build failed. Error:  - Failed to Compile. See Errors Above +Incremental build failed. Error:  Failed to Compile. See Errors Above diff --git a/rewatch/tests/snapshots/rename-file-with-interface.txt b/rewatch/tests/snapshots/rename-file-with-interface.txt index f5cce9e651..3e014015b5 100644 --- a/rewatch/tests/snapshots/rename-file-with-interface.txt +++ b/rewatch/tests/snapshots/rename-file-with-interface.txt @@ -1,7 +1,8 @@ - - No implementation file found for interface file (skipping): src/ModuleWithInterface.resi -Cleaned 2/56 + No implementation file found for interface file (skipping): src/ModuleWithInterface.resi +Cleaned 2/60 Parsed 1 source files +[rewatch] Copying file ModuleWithInterface2 to ocaml build path +[rewatch] Copying file Main to ocaml build path Compiled 2 modules The field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config' is deprecated and will be removed in a future version. diff --git a/rewatch/tests/snapshots/rename-file.txt b/rewatch/tests/snapshots/rename-file.txt index 4b0a9ca875..b2461d5e2b 100644 --- a/rewatch/tests/snapshots/rename-file.txt +++ b/rewatch/tests/snapshots/rename-file.txt @@ -1,5 +1,6 @@ -Cleaned 1/56 +Cleaned 1/60 Parsed 1 source files +[rewatch] Copying file Main2 to ocaml build path Compiled 1 modules The field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config' is deprecated and will be removed in a future version. diff --git a/rewatch/tests/snapshots/rename-interface-file.txt b/rewatch/tests/snapshots/rename-interface-file.txt index ef4b99a335..41549a4a22 100644 --- a/rewatch/tests/snapshots/rename-interface-file.txt +++ b/rewatch/tests/snapshots/rename-interface-file.txt @@ -1,7 +1,8 @@ - - No implementation file found for interface file (skipping): src/ModuleWithInterface2.resi -Cleaned 1/56 + No implementation file found for interface file (skipping): src/ModuleWithInterface2.resi +Cleaned 1/60 Parsed 1 source files +[rewatch] Copying file ModuleWithInterface to ocaml build path +[rewatch] Copying file Dep02 to ocaml build path Compiled 2 modules The field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config' is deprecated and will be removed in a future version. From 63a23b247ce88e936d86f3a7cc86370610a22feb Mon Sep 17 00:00:00 2001 From: tsnobip Date: Wed, 30 Jul 2025 10:35:49 +0200 Subject: [PATCH 11/13] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a80a23a4dc..dedffedcab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,6 +85,7 @@ - Fix fatal error when JSX expression used without configuring JSX in `rescript.json`. https://github.com/rescript-lang/rescript/pull/7656 - Rewatch: Only allow access to `"bs-dev-dependencies"` from `"type": "dev"` source files. https://github.com/rescript-lang/rescript/pull/7650 - Fix comment attached to array element. https://github.com/rescript-lang/rescript/pull/7672 +- Fix compilation of files starting with a lowercase letter. https://github.com/rescript-lang/rescript/pull/7700 #### :nail_care: Polish From 27018fd1d145c8eafbe607b384dc4944a831a04d Mon Sep 17 00:00:00 2001 From: tsnobip Date: Wed, 30 Jul 2025 10:41:25 +0200 Subject: [PATCH 12/13] update expected files --- rewatch/tests/format.sh | 4 ++-- rewatch/tests/suffix.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rewatch/tests/format.sh b/rewatch/tests/format.sh index cc6d72fc94..ccfef0f4e4 100755 --- a/rewatch/tests/format.sh +++ b/rewatch/tests/format.sh @@ -6,13 +6,13 @@ bold "Test: It should format all files" git diff --name-only ./ error_output=$("$REWATCH_EXECUTABLE" format --all) git_diff_file_count=$(git diff --name-only ./ | wc -l | xargs) -if [ $? -eq 0 ] && [ $git_diff_file_count -eq 6 ]; +if [ $? -eq 0 ] && [ $git_diff_file_count -eq 8 ]; then success "Test package formatted. Got $git_diff_file_count changed files." git restore . else error "Error formatting test package" - echo "Expected 4 files to be changed, got $git_diff_file_count" + echo "Expected 8 files to be changed, got $git_diff_file_count" echo $error_output exit 1 fi diff --git a/rewatch/tests/suffix.sh b/rewatch/tests/suffix.sh index a7d6ed8f83..aa67fcfde9 100755 --- a/rewatch/tests/suffix.sh +++ b/rewatch/tests/suffix.sh @@ -31,7 +31,7 @@ fi # Count files with new extension file_count=$(find ./packages -name *.res.js | wc -l) -if [ "$file_count" -eq 32 ]; +if [ "$file_count" -eq 36 ]; then success "Found files with correct suffix" else From 0615cc3179da36bfff3bd9628645db2617057a4d Mon Sep 17 00:00:00 2001 From: tsnobip Date: Wed, 30 Jul 2025 10:44:44 +0200 Subject: [PATCH 13/13] update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dedffedcab..f82d7a6234 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,7 +85,7 @@ - Fix fatal error when JSX expression used without configuring JSX in `rescript.json`. https://github.com/rescript-lang/rescript/pull/7656 - Rewatch: Only allow access to `"bs-dev-dependencies"` from `"type": "dev"` source files. https://github.com/rescript-lang/rescript/pull/7650 - Fix comment attached to array element. https://github.com/rescript-lang/rescript/pull/7672 -- Fix compilation of files starting with a lowercase letter. https://github.com/rescript-lang/rescript/pull/7700 +- Rewatch: fix compilation of files starting with a lowercase letter. https://github.com/rescript-lang/rescript/pull/7700 #### :nail_care: Polish @@ -102,6 +102,7 @@ - Rewatch: simplify getting bsc path. https://github.com/rescript-lang/rescript/pull/7634 - Rewatch: only get `"type": "dev"` source files for local packages. https://github.com/rescript-lang/rescript/pull/7646 - Rewatch: add support for `rescript -w` for compatibility. https://github.com/rescript-lang/rescript/pull/7649 +- Fix dev container. https://github.com/rescript-lang/rescript/pull/7700 # 12.0.0-beta.1