I have an issue with static js files is removed after deploy. I use code spitting to some components in my app (https://reactjs.org/docs/code-splitting.html).
The app is a web app, and some users have “installed” it on their home screens to use it as a native app.
When lazy loading parts of the web app, a user may browse around during a deploy. All .js chunks are replaced with new hashes when I deploy. When the user (with the old app) now navigates to some functionality that needs to load a chunk, the chunk with that hash does not exists on the server anymore.
So for currently loaded client, the chunk does not exist. Error: Loading chunk 7 failed.
For tech savvy users using the app in a browser, they can just refresh. But for those users who are using the app “installed” on their home screen, they can’t reload the page.
One solution would be to force refresh the app when a chunk fails to load, like this solution https://dev.to/goenning/how-to-retry-when-react-lazy-fails-mb5
But in addition, it would be great to keep old js chunks on the server for a while.
Is there a way to deploy a react app without wiping the old static files (except those that are overwritten, of course)?