Skip to content

Commit c8d71af

Browse files
tsnobipnojaf
andauthored
Fix rewatch compilation of file starting with a lowercase letter (#7700)
* add file-casing test repos to rewatch tests * fix dev container * fix compilation of files starting with lowercase letter --------- Co-authored-by: nojaf <florian.verdonck@outlook.com>
1 parent e4b6669 commit c8d71af

27 files changed

+231
-43
lines changed

.devcontainer/.dockerignore

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
*~
2+
_build
3+
*.obj
4+
*.out
5+
*.compile
6+
*.native
7+
*.byte
8+
*.cmo
9+
*.annot
10+
*.cmi
11+
*.cmx
12+
*.cmt
13+
*.cmti
14+
*.cma
15+
*.a
16+
*.cmxa
17+
*.obj
18+
*~
19+
*.annot
20+
*.mj
21+
*.bak
22+
*.swp
23+
*.swo
24+
*.flambda
25+
*.jsx
26+
*.lambda
27+
*.rawlambda
28+
*.s
29+
*.o
30+
*.lam
31+
*.0.js
32+
*#
33+
*.log
34+
.#*
35+
*.cmj
36+
*.rawlambda
37+
*.lambda
38+
*.zip
39+
*.mlast
40+
*.mliast
41+
42+
.idea
43+
.DS_Store
44+
45+
node_modules
46+
*.dump
47+
coverage
48+
49+
.ninja_log
50+
.bsdeps
51+
.bsbuild
52+
lib/ocaml
53+
tests/build_tests/*/lib/
54+
#ignore temporary directory
55+
*.goog.js
56+
*.jsoo.js
57+
*.so
58+
tmp/
59+
tracing*.json
60+
61+
_opam
62+
63+
.env
64+
playground/packages/
65+
playground/stdlib/
66+
playground/*.cmj
67+
playground/*.cmi
68+
playground/.netrc
69+
playground/compiler.*js
70+
71+
rewatch/target/
72+
rewatch/rewatch
73+
74+
tests/tools_tests/**/*.res.js
75+
tests/tools_tests/lib
76+
tests/analysis_tests*/lib
77+
tests/analysis_tests/**/*.bs.js
78+
79+
/linux/*.exe
80+
/linuxarm64/*.exe
81+
/darwin/*.exe
82+
/darwinarm64/*.exe
83+
/win32/*.exe
84+
85+
.yarn/*
86+
!.yarn/patches
87+
!.yarn/plugins
88+
!.yarn/releases
89+
!.yarn/sdks
90+
!.yarn/versions
91+
92+
*.tsbuildinfo
93+
94+
# package tarballs
95+
package.tgz
96+
*.exe
97+
98+
/ninja/ninja
99+
/ninja/build.ninja

.devcontainer/Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ FROM mcr.microsoft.com/devcontainers/rust:1-1-bookworm
22
LABEL org.opencontainers.image.authors="Christoph Knittel <ck@cca.io>"
33
LABEL org.opencontainers.image.description="Docker image for ReScript development."
44

5-
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
5+
RUN sudo apt-get update && export DEBIAN_FRONTEND=noninteractive \
66
&& apt-get -y install --no-install-recommends \
7-
yarn \
8-
opam \
7+
cmake \
8+
ninja-build \
99
musl-tools \
1010
python-is-python3 \
1111
&& rm -rf /var/lib/apt/lists/*
12+
13+
# Install OPAM
14+
ARG OPAM_VERSION=2.4.1
15+
RUN printf '\n\n' | bash -c "sh <(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh) --version $OPAM_VERSION"

.devcontainer/devcontainer.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
"name": "ReScript Compiler",
33
"build": {
44
"context": ".",
5-
"dockerfile": "Dockerfile"
5+
"dockerfile": "Dockerfile",
6+
"args": {
7+
"USER_UID": "${localEnv:UID}",
8+
"USER_GID": "${localEnv:GID}"
9+
}
610
},
711
"features": {
812
"ghcr.io/devcontainers/features/github-cli:1": {
@@ -23,5 +27,7 @@
2327
]
2428
}
2529
},
26-
"postCreateCommand": ".devcontainer/postCreate.sh"
30+
"postCreateCommand": ".devcontainer/postCreate.sh",
31+
"remoteUser": "vscode",
32+
"containerUser": "vscode"
2733
}

.devcontainer/postCreate.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
# Install dev dependencies from OPAM
44
opam init -y --bare --disable-sandboxing
5-
opam switch create 5.3.0 --packages ocaml-option-static
6-
opam install . --deps-only -y
7-
8-
# For IDE support, install the OCaml language server
9-
opam install ocaml-lsp-server -y
5+
opam switch create 5.3.0
6+
opam install . --deps-only --with-test --with-dev-setup -y
107

118
# Add OPAM environment setup to shell startup script
129
echo 'eval $(opam env)' >> ~/.zshrc
1310
echo 'eval $(opam env)' >> ~/.bashrc
1411

15-
npm install --ignore-scripts
12+
nvm install
13+
14+
corepack enable
15+
printf "\n" | yarn

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
- Fix fatal error when JSX expression used without configuring JSX in `rescript.json`. https://github.com/rescript-lang/rescript/pull/7656
8686
- Rewatch: Only allow access to `"bs-dev-dependencies"` from `"type": "dev"` source files. https://github.com/rescript-lang/rescript/pull/7650
8787
- Fix comment attached to array element. https://github.com/rescript-lang/rescript/pull/7672
88+
- Rewatch: fix compilation of files starting with a lowercase letter. https://github.com/rescript-lang/rescript/pull/7700
8889

8990
#### :nail_care: Polish
9091

@@ -101,6 +102,7 @@
101102
- Rewatch: simplify getting bsc path. https://github.com/rescript-lang/rescript/pull/7634
102103
- Rewatch: only get `"type": "dev"` source files for local packages. https://github.com/rescript-lang/rescript/pull/7646
103104
- Rewatch: add support for `rescript -w` for compatibility. https://github.com/rescript-lang/rescript/pull/7649
105+
- Fix dev container. https://github.com/rescript-lang/rescript/pull/7700
104106

105107
# 12.0.0-beta.1
106108

rewatch/src/build/compile.rs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,8 @@ fn compile_file(
578578
ast_path.to_string_lossy()
579579
)),
580580
}?;
581-
let module_name = helpers::file_path_to_module_name(implementation_file_path, &package.namespace);
581+
let basename =
582+
helpers::file_path_to_compiler_asset_basename(implementation_file_path, &package.namespace);
582583
let has_interface = module.get_interface().is_some();
583584
let is_type_dev = module.is_type_dev;
584585
let to_mjs_args = compiler_args(
@@ -631,40 +632,35 @@ fn compile_file(
631632
// because editor tooling doesn't support namespace entries yet
632633
// we just remove the @ for now. This makes sure the editor support
633634
// doesn't break
634-
.join(format!("{module_name}.cmi")),
635-
ocaml_build_path_abs.join(format!("{module_name}.cmi")),
635+
.join(format!("{basename}.cmi")),
636+
ocaml_build_path_abs.join(format!("{basename}.cmi")),
636637
);
637638
let _ = std::fs::copy(
638-
package
639-
.get_build_path()
640-
.join(dir)
641-
.join(format!("{module_name}.cmj")),
642-
ocaml_build_path_abs.join(format!("{module_name}.cmj")),
639+
package.get_build_path().join(dir).join(format!("{basename}.cmj")),
640+
ocaml_build_path_abs.join(format!("{basename}.cmj")),
643641
);
642+
println!("[rewatch] Copying file {basename} to ocaml build path");
644643
let _ = std::fs::copy(
645644
package
646645
.get_build_path()
647646
.join(dir)
648647
// because editor tooling doesn't support namespace entries yet
649648
// we just remove the @ for now. This makes sure the editor support
650649
// doesn't break
651-
.join(format!("{module_name}.cmt")),
652-
ocaml_build_path_abs.join(format!("{module_name}.cmt")),
650+
.join(format!("{basename}.cmt")),
651+
ocaml_build_path_abs.join(format!("{basename}.cmt")),
653652
);
654653
} else {
655654
let _ = std::fs::copy(
656655
package
657656
.get_build_path()
658657
.join(dir)
659-
.join(format!("{module_name}.cmti")),
660-
ocaml_build_path_abs.join(format!("{module_name}.cmti")),
658+
.join(format!("{basename}.cmti")),
659+
ocaml_build_path_abs.join(format!("{basename}.cmti")),
661660
);
662661
let _ = std::fs::copy(
663-
package
664-
.get_build_path()
665-
.join(dir)
666-
.join(format!("{module_name}.cmi")),
667-
ocaml_build_path_abs.join(format!("{module_name}.cmi")),
662+
package.get_build_path().join(dir).join(format!("{basename}.cmi")),
663+
ocaml_build_path_abs.join(format!("{basename}.cmi")),
668664
);
669665
}
670666

rewatch/testrepo/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"packages/with-dev-deps",
1212
"packages/compiled-by-legacy",
1313
"packages/nonexisting-dev-files",
14-
"packages/deprecated-config"
14+
"packages/deprecated-config",
15+
"packages/file-casing",
16+
"packages/file-casing-no-namespace"
1517
]
1618
},
1719
"dependencies": {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "@testrepo/file-casing-no-namespace",
3+
"version": "0.0.1",
4+
"keywords": [
5+
"rescript"
6+
],
7+
"author": "",
8+
"license": "MIT"
9+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "@testrepo/file-casing-no-namespace",
3+
"sources": [
4+
{
5+
"dir": "src",
6+
"subdirs": true
7+
}
8+
],
9+
"package-specs": [
10+
{
11+
"module": "es6",
12+
"in-source": true
13+
}
14+
],
15+
"suffix": ".mjs",
16+
"dependencies": [],
17+
"compiler-flags": [],
18+
"jsx": {
19+
"version": 4
20+
}
21+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Generated by ReScript, PLEASE EDIT WITH CARE
2+
3+
import * as Produce from "./produce.mjs";
4+
5+
let x = Produce.meh(1);
6+
7+
export {
8+
x,
9+
}
10+
/* x Not a pure module */

0 commit comments

Comments
 (0)