Skip to content

Commit dca052b

Browse files
authored
Fix .bs.js timestamp being reset to 1970-01-01 when there are warnings (rescript-lang#5738)
1 parent 62f92f1 commit dca052b

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#### :bug: Bug Fix
1616

17+
- Fix issue with changes not being applied with React Native's Metro bundler for files with warnings https://github.com/rescript-lang/rescript-compiler/pull/5738
1718
- Fix emitting unary minus for floats in case of negative constants https://github.com/rescript-lang/rescript-compiler/pull/5737
1819
- Fix issue where a spread `...x` in non-last position would not be reported as syntax error https://github.com/rescript-lang/syntax/pull/673/
1920
- Fix issue where the formatter would delete `async` in a function with labelled arguments.

jscomp/core/lam_compile_main.ml

+10-4
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

+9-4
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

+8-3
Original file line numberDiff line numberDiff line change
@@ -274592,9 +274592,14 @@ let lambda_as_module
274592274592
target_file output_chan );
274593274593
if !Warnings.has_warnings then begin
274594274594
Warnings.has_warnings := false ;
274595-
274596-
if Sys.file_exists target_file then begin
274597-
Bs_hash_stubs.set_as_old_file target_file
274595+
(* 5206: When there were warnings found during the compilation, we want the file
274596+
to be rebuilt on the next "rescript build" so that the warnings keep being shown.
274597+
Set the timestamp of the ast file to 1970-01-01 to make this rebuild happen.
274598+
(Do *not* set the timestamp of the JS output file instead
274599+
as that does not play well with every bundler.) *)
274600+
let ast_file = output_prefix ^ Literals.suffix_ast in
274601+
if Sys.file_exists ast_file then begin
274602+
Bs_hash_stubs.set_as_old_file ast_file
274598274603
end
274599274604

274600274605
end

0 commit comments

Comments
 (0)