.bs.js gets timestamp 1970-01-01 if .res had a warning
This just cost me almost a day to figure out. I was upgrading and refactoring a large (ReScript) React Native app, and suddenly Metro Bundler was not picking up any changes anymore until I restarted it with --reset-cache. Which I had to repeat every time I made a change. 🤯
The reason was that, in the process of refactoring, I had introduced some "unused open" warnings that I was planning to resolve later.
For the files with warnings, correct JS output was generated in the .bs.js, but the timestamp of the .bs.js was set to / remained 1970-01-01, so Metro did not refresh its cache and therefore the changes I made never became active in my app.
I think this is quite a serious issue and might affect other bundlers, too. I believe I have just not run into it before because I usually don't leave any warnings unresolved.
Note the work around is turn warn-error. This is a trade off to play. We set the time stamp so that the build system could always produce the same output (warnings are not flushed on a rebuild)
Ok, thanks for the information. I was already suspecting that this might be due to the "do not flush warnings" feature.
Still, the current workaround can lead to very unexpected behavior, and most probably not just with Metro.
Can you conceive of a different way to solve this problem that allows us to keep correct change dates for the JS output files with warnings?
will set the .cmj file instead, note it will trigger some unneeded rebuild, but this will only affect code who has warnings, so it may not be a big deal
I just got bitten by this again (and wasted more time than I'd like to admit) - can we expect it to be resolved soon?
I got bitten by this... too.
I learned a lot about watchman and react native caching as the wrong timestamp was stopping "fast refresh" from working there.
I'd imagine it probably breaks other caching systems too.
I just got bitten by this again (and wasted more time than I'd like to admit) - can we expect it to be resolved soon?
Same here. This really needs to be mentioned on the Rescript RN page because others are going to waste time trying to fix auto refresh.
It seems this also causes similar problems with Tailwind CSS (styles not being refreshed).
will set the .cmj file instead, note it will trigger some unneeded rebuild, but this will only affect code who has warnings, so it may not be a big deal
@bobzhang It would be great if you could look into this when you have some time. It would really make the lives of ReScript React Native developers a lot easier, and I would love to be able to include this in the 10.0 or 10.1 release.
In my desperation, I now tried to implement Bob's suggestion myself:
will set the .cmj file instead, note it will trigger some unneeded rebuild, but this will only affect code who has warnings, so it may not be a big deal
Indeed I managed to reset the timestamp of the .cmj instead of the bs.js when there were warnings, but it did not work as intended. Instead, it produced the error
rescript: error: '../bs/src/Test.cmj', needed by 'Test.cmj', missing and no known rule to make it
(Test.cmj is present, but has the 1970-01-01 timestamp set.)
Looking for some guidance here. @bobzhang @cristianoc
@bobzhang I am willing to invest some time here to get this finally fixed.
Before I dig into ninja, I would need some guidance on how to proceed. E.g., instead of the timestamp solution which seems problematic no matter which file's timestamp you modify, maybe some kind of additional "marker" file should be created for files with warnings?