Skip to content
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

Hot reload on server side #75

Open
mostlyjason opened this issue Aug 4, 2016 · 3 comments
Open

Hot reload on server side #75

mostlyjason opened this issue Aug 4, 2016 · 3 comments

Comments

@mostlyjason
Copy link

Hi I'll start by saying great starter kit! I'm really liking the Typescript. I've got this running on my dev machine and I'm trying to do a hot module replacement. It looks like the code is updated automatically on the client side, but the node server is not updated.

As a test, I edited Home/index.tsx and replaced "Hello" with "Hello2!", and then saved the file. At this point webpack builds and the browser is updated through HMR.

[HMR] connected
client.js:127 [HMR] bundle rebuilding
client.js:130 [HMR] bundle rebuilt in 2495ms
process-update.js:27 [HMR] Checking for updates on the server...
process-update.js:100 [HMR] Updated modules:
process-update.js:102 [HMR]  - ./src/app/containers/Home/index.tsx
process-update.js:107 [HMR] App is up to date.

When I refresh the page to trigger a server-side rendering I get the following error message:

warning.js:44 Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:
 (client) a-reactid="15">Hello2!</p></div></sectio
 (server) a-reactid="15">Hello!</p></div></section

It appears that the server has the older version of the file. The only way I found to update it is by restarting the server. Does hot reloading on the server side work for other people? If so, it might be something wrong about my system configuration that I should investigate. If this is not supported, should we consider adding it?

@altaywtf
Copy link
Contributor

altaywtf commented Aug 6, 2016

We are aware of this issue and will look for a solution on the following weeks. If you have any suggestions or efforts related to this problem, please don't hesitate to share it or open a pull request.

Thanks!

@mostlyjason
Copy link
Author

Okay thanks! At least I know it's not something strange about my system. I'll report back if I find a solution but for right now I'm just restarting the server as needed.

@mostlyjason
Copy link
Author

mostlyjason commented Aug 20, 2016

So I played around with this and got something working. Basically, I configured webpack to watch for changes and recompile a new server bundle when there are. Then I configured nodemon to restart the node server when the server bundle changes. This is great because any changes to routes or API code get updated automatically. The disadvantage is that it's slower because the node server has to restart. Also, the hot module reload on the browser seems to work sometimes after the connection reset, but it seems a little inconsistent. It would be even better if we could do a hot module reload on the server side but I haven't figured out how to get that working yet. I'd be happy to submit my code in a branch, but I'm not sure it's really polished enough for master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants