remix icon indicating copy to clipboard operation
remix copied to clipboard

🗺️ HMR

Open ryanflorence opened this issue 2 years ago • 1 comments

Clientside assets only, expect the server to do it's own reboot/reload etc. when the server assets change (since they all do anyway, and in the case of express, just do --watch in v19)

PRs

  • [ ] #5259

ryanflorence avatar Jan 24 '23 19:01 ryanflorence

@jacob-ebey and Pedro to pair on this, especially in the beginning

ryanflorence avatar Jan 24 '23 19:01 ryanflorence

How we handle different types of updates

Prototype

Any code changes: HMR new modules only applying React Refresh after routes revalidate

Platonic ideal

Detect addition or change of loaders so we only revalidate those.

Removal shouldn't require special handling. Stale data can just be kept around and garbage collected. Or we can "revalidate" it which will instantly clean it up since there's nothing to do.

How to detect loader changes

Hash the loader function. Ideally we could detect subtle things like an import alias changing or an import source changing even when loader source code stays the same, but that's HARD, so not gonna do that. At least not now.

For correctness, we can err on the side of doing a full revalidation for this loader whenever anything changes in its file. For speed, we could err on the side of only revalidating when loader hash changes, but might miss out on subtle cases like the ones mentioned above.

Since we currently have "double save = full refresh" dev snacks, we could go for the "speed optimized" approach and let users double save to force a revalidation when those subtle cases come up, but they should be exceedingly rare.

pcattori avatar Jan 30 '23 18:01 pcattori