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

react hmr example #25

Closed
dKab opened this issue Feb 17, 2017 · 13 comments
Closed

react hmr example #25

dKab opened this issue Feb 17, 2017 · 13 comments

Comments

@dKab
Copy link

dKab commented Feb 17, 2017

I'd love to see working example of koa-webpack with webpack 2 and react-hot-loader3

@cmoad
Copy link

cmoad commented Feb 23, 2017

Created #30 because I also wanted to see this.

@dKab
Copy link
Author

dKab commented Feb 23, 2017

@cmoad I managed to get it working in my setup. You may take a look at it here: https://github.com/dKab/recipy-book

@shellscape
Copy link
Owner

@dKab wonderful! could I link to your project in koa-webpack's README?

@dKab
Copy link
Author

dKab commented Feb 23, 2017

@shellscape sure, no problem. Thanks for the package by the way.

@cmoad
Copy link

cmoad commented Feb 24, 2017

Perhaps I'm misunderstanding, but I don't see that you are hot reloading the server code. I'm trying to setup a project with only server code (no react). I also see in your readme:

Hot reloading is enabled. Client bundle will be recompiled with every change, however server bundle won't (HMR wouldn't work if server was recompiled on every change).

@dKab
Copy link
Author

dKab commented Feb 24, 2017

@cmoad

but I don't see that you are hot reloading the server code

Oops. Sorry. I din't know hmr can can be applied to server code as well as to client.

@cmoad
Copy link

cmoad commented Feb 24, 2017

Perhaps it can't and that's why I am struggling.

@dKab
Copy link
Author

dKab commented Feb 24, 2017

But I don't I think I grasp the concept of hmr on the server. On the client it's pretty clear - bundle is updated on the fly and thus you don't have to reload the browser to see changes. On the other hand what would be the idea of hmr on the server side? I mean why the solution when you track changes in source files and recompile server bundle and restart node with new bundle wouldn't work for you?

To achieve this you could (assuming you use webpack for budling server code) start webpack in watch mode and use something like nodemon to restart your server script when bundle is changed.

Or am I missing something?

@shellscape
Copy link
Owner

From webpack-hot-middleware's readme:

This module is only concerned with the mechanisms to connect a browser client to a webpack server & receive updates. It will subscribe to changes from the server and execute those changes using webpack's HMR api.

That links to the HMR API which to me reads that it's only concerned with client-side things, as that's webpack's targeted focus.

The suggestion by @dKab sounds like a winner. But server-side module reloading may be out of scope for this module, given the client-side focus. It sounds like something that needs to work externally in conjunction with koa-webpack.

@bryanlarsen
Copy link

Note: the linked example abandoned koa-webpack, claiming it was broken: dKab/recipe-book@701deac

@shellscape
Copy link
Owner

@bryanlarsen that's humorous, but thank you for sharing for the benefit of others. closing this issue as it's pretty stale. we'll welcome contributed examples for different platforms (like React) but it's not something that's a priority at the moment.

@damianobarbati
Copy link

Was anyone able to reproduce a public working example with react?

@mrchief
Copy link

mrchief commented Jan 19, 2018

I have React hot loading working with "koa-webpack": "^1.0.0". "koa-webpack": "^2.0.3", seems to break it and I haven't found the missing link yet. Probably I'll go back to using v1.

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

No branches or pull requests

6 participants