Skip to content

Commit 45cb98c

Browse files
committed
Fix .bs.js timestamp being reset to 1970-01-01 when there are warnings
1 parent 8cbb4da commit 45cb98c

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

jscomp/core/lam_compile_main.ml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,18 @@ let lambda_as_module
327327
if !Warnings.has_warnings then begin
328328
Warnings.has_warnings := false ;
329329

330-
# 322 "core/lam_compile_main.pp.ml"
331-
if Sys.file_exists target_file then begin
332-
Bs_hash_stubs.set_as_old_file target_file
330+
# 321 "core/lam_compile_main.pp.ml"
331+
(* 5206: When there were warnings found during the compilation, we want the file
332+
to be rebuilt on the next "rescript build" so that the warnings keep being shown.
333+
Set the timestamp of the ast file to 1970-01-01 to make this rebuild happen.
334+
(Do *not* set the timestamp of the JS output file instead
335+
as that does not play well with every bundler.) *)
336+
let ast_file = output_prefix ^ Literals.suffix_ast in
337+
if Sys.file_exists ast_file then begin
338+
Bs_hash_stubs.set_as_old_file ast_file
333339
end
334340

335-
# 326 "core/lam_compile_main.pp.ml"
341+
# 331 "core/lam_compile_main.pp.ml"
336342
end
337343
)
338344

jscomp/core/lam_compile_main.pp.ml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,15 @@ let lambda_as_module
317317
target_file output_chan );
318318
if !Warnings.has_warnings then begin
319319
Warnings.has_warnings := false ;
320-
#ifdef BROWSER
321-
#else
322-
if Sys.file_exists target_file then begin
323-
Bs_hash_stubs.set_as_old_file target_file
320+
#ifndef BROWSER
321+
(* 5206: When there were warnings found during the compilation, we want the file
322+
to be rebuilt on the next "rescript build" so that the warnings keep being shown.
323+
Set the timestamp of the ast file to 1970-01-01 to make this rebuild happen.
324+
(Do *not* set the timestamp of the JS output file instead
325+
as that does not play well with every bundler.) *)
326+
let ast_file = output_prefix ^ Literals.suffix_ast in
327+
if Sys.file_exists ast_file then begin
328+
Bs_hash_stubs.set_as_old_file ast_file
324329
end
325330
#endif
326331
end

lib/4.06.1/whole_compiler.ml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274502,9 +274502,14 @@ let lambda_as_module
274502274502
target_file output_chan );
274503274503
if !Warnings.has_warnings then begin
274504274504
Warnings.has_warnings := false ;
274505-
274506-
if Sys.file_exists target_file then begin
274507-
Bs_hash_stubs.set_as_old_file target_file
274505+
(* 5206: When there were warnings found during the compilation, we want the file
274506+
to be rebuilt on the next "rescript build" so that the warnings keep being shown.
274507+
Set the timestamp of the ast file to 1970-01-01 to make this rebuild happen.
274508+
(Do *not* set the timestamp of the JS output file instead
274509+
as that does not play well with every bundler.) *)
274510+
let ast_file = output_prefix ^ Literals.suffix_ast in
274511+
if Sys.file_exists ast_file then begin
274512+
Bs_hash_stubs.set_as_old_file ast_file
274508274513
end
274509274514

274510274515
end

0 commit comments

Comments
 (0)