Skip to content

Commit 6d4c90f

Browse files
committed
Fix path construction to handle both bsb and rewatch
bsb passes path='.' and expects source_subdir to be extracted from output_prefix. rewatch passes path=file_path.parent() which already contains the full directory. Now check if path is a base directory (., lib/es6, etc.) and only then extract source_subdir from output_prefix. Otherwise use path as-is.
1 parent 4b9142e commit 6d4c90f

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

compiler/core/lam_compile_main.ml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -304,19 +304,25 @@ let lambda_as_module
304304
let basename =
305305
Ext_namespace.change_ext_ns_suffix (Filename.basename output_prefix) suffix
306306
in
307-
(* Extract source subdirectory from output_prefix (e.g., "src/acyc" from "src/acyc/Node") *)
308-
let source_subdir = Filename.dirname output_prefix in
309307
(* Construct target path:
310-
- path is the base output directory from config (e.g., "." for in-source, "../lib/es6" for out-of-source)
311-
- source_subdir preserves the source directory structure
308+
- For bsb (path="."): extract source subdir from output_prefix
309+
- For rewatch: path already contains full directory from file_path.parent()
312310
- basename is the final filename *)
313311
let target_file =
314-
(Lazy.force Ext_path.package_dir //
315-
path //
316-
source_subdir //
317-
basename
318-
(* #913 only generate little-case js file *)
319-
) in
312+
if path = "." || path = "lib/bs" || path = "lib/es6" || path = "lib/es6-global" then
313+
(* Legacy bsb mode: path is base dir, extract source subdir from output_prefix *)
314+
let source_subdir = Filename.dirname output_prefix in
315+
(Lazy.force Ext_path.package_dir //
316+
path //
317+
source_subdir //
318+
basename)
319+
else
320+
(* Rewatch mode: path already contains full directory *)
321+
(Lazy.force Ext_path.package_dir //
322+
path //
323+
basename
324+
(* #913 only generate little-case js file *)
325+
) in
320326
(if not !Clflags.dont_write_files then
321327
Ext_pervasives.with_file_as_chan
322328
target_file output_chan );

tests/tests/src/core/Core_TempTests.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
77
import * as Stdlib_Float from "@rescript/runtime/lib/es6/Stdlib_Float.js";
88
import * as Stdlib_BigInt from "@rescript/runtime/lib/es6/Stdlib_BigInt.js";
99
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
10-
import * as Core_IntlTests from "./intl/Core_IntlTests.mjs";
10+
import * as Core_IntlTests from "./Core_IntlTests.mjs";
1111
import * as Primitive_bigint from "@rescript/runtime/lib/es6/Primitive_bigint.js";
1212
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
1313

0 commit comments

Comments
 (0)