Skip to content

Commit 3f5e32c

Browse files
committed
Fix finding the standard library for pnpm some more
1 parent dcd0560 commit 3f5e32c

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

compiler/ext/config.ml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,30 @@ let standard_library =
1212
|> List.rev
1313
with
1414
(* 1. Packages installed via pnpm
15-
- bin: node_modules/.pnpm/@rescript+darwin-arm64@12.0.0-alpha.13/node_modules/@rescript/darwin-arm64/bin
16-
- stdlib: node_modules/rescript/lib/ocaml (symlink)
15+
- bin: node_modules/.pnpm/@rescript+darwin-arm64@12.0.0-alpha.15/node_modules/@rescript/darwin-arm64/bin
16+
- stdlib: node_modules/.pnpm/rescript@12.0.0-alpha.15/node_modules/rescript/lib/ocaml
1717
*)
18-
| "bin" :: _platform :: "@rescript" :: "node_modules" :: _package :: ".pnpm"
19-
:: "node_modules" :: rest ->
20-
build_path rest ["node_modules"; "rescript"; "lib"; "ocaml"]
18+
| "bin" :: _platform :: "@rescript" :: "node_modules" :: bin_package
19+
:: ".pnpm" :: "node_modules" :: rest -> (
20+
match bin_package |> String.split_on_char '@' with
21+
| [""; _package_name; version] ->
22+
build_path rest
23+
[
24+
"node_modules";
25+
".pnpm";
26+
"rescript@" ^ version;
27+
"node_modules";
28+
"rescript";
29+
"lib";
30+
"ocaml";
31+
]
32+
| _ ->
33+
(* The above might not match, e.g., for the installation test where we have
34+
- bin: node_modules/.pnpm/@rescript+darwin-arm64@https+++pkg.pr.new+rescript-lang+rescript+@rescript+darwin-arm64_dc084c3d4ed1dbfd250a9747e43c07d8/node_modules/@rescript/darwin-arm64/bin/
35+
- stdlib: node_modules/.pnpm/rescript@https+++pkg.pr.new+rescript-lang+rescript@324acbeded5d684d89b26ab38d1d86eff5880b1d/node_modules/rescript/lib/ocaml
36+
In that case try to fall back to rescript/lib/ocaml which should be present as a symlink.
37+
*)
38+
build_path rest ["node_modules"; "rescript"; "lib"; "ocaml"])
2139
(* 2. Packages installed via npm
2240
- bin: node_modules/@rescript/{platform}/bin
2341
- stdlib: node_modules/rescript/lib/ocaml

0 commit comments

Comments
 (0)