File tree Expand file tree Collapse file tree 2 files changed +32
-10
lines changed Expand file tree Collapse file tree 2 files changed +32
-10
lines changed Original file line number Diff line number Diff line change 2929
3030#### :house : Internal
3131
32+ - Editor: resolve @rescript/runtime via environment variable RESCRIPT_RUNTIME. https://github.com/rescript-lang/rescript/pull/8023
33+
3234# 12.0.0-rc.4
3335
3436#### :boom : Breaking Change
Original file line number Diff line number Diff line change @@ -5,19 +5,39 @@ let namespacedName namespace name =
55
66let ( /+ ) = Filename. concat
77
8+ (*
9+ Editor tooling can more accurately resolve the runtime path and will try and pass it via an environment variable.
10+ Example path: "test-stdlib/node_modules/.pnpm/@[email protected] /node_modules/@rescript/runtime" 11+ *)
12+
813let getRuntimeDir rootPath =
914 match ! Cfg. isDocGenFromCompiler with
1015 | false -> (
11- let result =
12- ModuleResolution. resolveNodeModulePath ~start Path:rootPath
13- " @rescript/runtime"
14- in
15- match result with
16- | Some path -> Some path
17- | None ->
18- let message = " @rescript/runtime could not be found" in
19- Log. log message;
20- None )
16+ (* First check RESCRIPT_RUNTIME environment variable, like bsc does *)
17+ match Sys. getenv_opt " RESCRIPT_RUNTIME" with
18+ | Some envPath ->
19+ if Debug. verbose () then
20+ Printf. printf " [getRuntimeDir] Using RESCRIPT_RUNTIME=%s\n " envPath;
21+ Some envPath
22+ | None -> (
23+ let result =
24+ ModuleResolution. resolveNodeModulePath ~start Path:rootPath
25+ " @rescript/runtime"
26+ in
27+ match result with
28+ | Some path ->
29+ if Debug. verbose () then
30+ Printf. printf " [getRuntimeDir] Resolved via node_modules: %s\n " path;
31+ Some path
32+ | None ->
33+ let message = " @rescript/runtime could not be found" in
34+ Log. log message;
35+ if Debug. verbose () then
36+ Printf. printf
37+ " [getRuntimeDir] Failed to resolve @rescript/runtime from \
38+ rootPath=%s\n "
39+ rootPath;
40+ None ))
2141 | true -> Some rootPath
2242
2343let getLibBs path = Files. ifExists (path /+ " lib" /+ " bs" )
You can’t perform that action at this time.
0 commit comments