-
Notifications
You must be signed in to change notification settings - Fork 70
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
Breaking hotreloading #27
Comments
Hey @ChrisCinelli ! Sorry for getting back to you so late. In general I don't have any good idea on how babel-watch could support such a complex use-case. If you have any suggestion on how precisely this could work I'd be keen to listen. I'm not entirely sure if I understand how your setup works, so I'm assuming you have webpack that bundles JS and then also serverside rendering that uses the same client code, right? If so I worked on an app with very similar setup and the way we solved it was by starting two processes: one with webpack and the second with server code. Webpack will handle client code updates and hot reloading (webpack will keep socket connection open when updating client JS files) whereas babel-watch will handle restarting the server Let me know if that helps! |
It is a little more tricky when you have isomorphic code. I.e. component code that is used both on the server and frontend. Splitting server and client process does not help. Going back on what I was asking, I think the tricky part is to find a good way for the process to communicate to babel-watch. Maybe something like: http://stackoverflow.com/a/36995148/407245 So if you start |
@ChrisCinelli what do you mean by "more tricky"? I use the setup with two processes I described with isomorphic code (one process runs webpack, the other runs server code with server side rendering of react app) Are you sure restarting the prcess whenever page reload is requested would solve your problem? If the server process dies when you're reloading your page the browser would get no response back. So in my opinion it is not sufficient to just wait with restart but I might be missing something... |
I will try to be more clear. In an isomorphic app you have the code of components (that I keep in a "client" folder) that is shared and runs on both the server and the browser. Ideally you are able to modify HTML and CSS of the component and the react hot-reloader will be able to push the new version to the browser without restarting the server. The hot-reloader, though, does not push the code to the server. For that you need a server restart. Now I tried 2 things:
I am not sure how using 2 different processes can fix this problem. Both processes will have to detect changes in the "client" folder and once you modify a component file in it, they will both restart. Or am I misunderstanding what you suggested? What I am suggesting is to have |
This is a pretty complex use case that we don't intend to actually support. However, I'd be happy to accept a PR that would wait for a signal to do the reload, if you'd like. |
Thank you very much for the great job with
babel-watch
.Our restart time went way down since we started using it.
The problem that we still have is that the autowatch breaks the
react-hot-loader
in our universal configuration.If we run the process with just
cross-env babel-watch -r dotenv/config index.js dotenv_config_silent=true
, when a component is changed, the server restart. This breaks the socket connection of the hot reload (in the console we see::8000/__webpack_hmr:1 GET http://localhost:8000/__webpack_hmr net::ERR_INCOMPLETE_CHUNKED_ENCODING
)The workaround that we found was adding
-D --watch server
that watches ONLY the server folder.This is still less than ideal. Now the server does not restart if a component is changed but only when a file in the
/server
folder changes. The problem is that in order for the server to reload a component for a full page reload we have to manuallyCtrl-C
and restart the server.Ideally when a component is updated, the server set a flag and on the next full page reload, the server is restarted.
I wonder if there is already a way to fix this or if babel-watch could expose a way for the process to detect if a file changes and delay the reload until an event is triggered (i.e. access to a
react-router
route).The text was updated successfully, but these errors were encountered: