Skip to content

Fix .bs.js timestamp being reset to 1970-01-01 when there are warnings #5738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#### :bug: Bug Fix

- 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
- Fix emitting unary minus for floats in case of negative constants https://github.com/rescript-lang/rescript-compiler/pull/5737
- 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/
- Fix issue where the formatter would delete `async` in a function with labelled arguments.
Expand Down
14 changes: 10 additions & 4 deletions jscomp/core/lam_compile_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,18 @@ let lambda_as_module
if !Warnings.has_warnings then begin
Warnings.has_warnings := false ;

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

# 326 "core/lam_compile_main.pp.ml"
# 331 "core/lam_compile_main.pp.ml"
end
)

Expand Down
13 changes: 9 additions & 4 deletions jscomp/core/lam_compile_main.pp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,15 @@ let lambda_as_module
target_file output_chan );
if !Warnings.has_warnings then begin
Warnings.has_warnings := false ;
#ifdef BROWSER
#else
if Sys.file_exists target_file then begin
Bs_hash_stubs.set_as_old_file target_file
#ifndef BROWSER
(* 5206: When there were warnings found during the compilation, we want the file
to be rebuilt on the next "rescript build" so that the warnings keep being shown.
Set the timestamp of the ast file to 1970-01-01 to make this rebuild happen.
(Do *not* set the timestamp of the JS output file instead
as that does not play well with every bundler.) *)
let ast_file = output_prefix ^ Literals.suffix_ast in
if Sys.file_exists ast_file then begin
Bs_hash_stubs.set_as_old_file ast_file
end
#endif
end
Expand Down
11 changes: 8 additions & 3 deletions lib/4.06.1/whole_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -274592,9 +274592,14 @@ let lambda_as_module
target_file output_chan );
if !Warnings.has_warnings then begin
Warnings.has_warnings := false ;

if Sys.file_exists target_file then begin
Bs_hash_stubs.set_as_old_file target_file
(* 5206: When there were warnings found during the compilation, we want the file
to be rebuilt on the next "rescript build" so that the warnings keep being shown.
Set the timestamp of the ast file to 1970-01-01 to make this rebuild happen.
(Do *not* set the timestamp of the JS output file instead
as that does not play well with every bundler.) *)
let ast_file = output_prefix ^ Literals.suffix_ast in
if Sys.file_exists ast_file then begin
Bs_hash_stubs.set_as_old_file ast_file
end

end
Expand Down