Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from megatolya/patch-1
Fix koa api example
- Loading branch information
Fix koa api example
1ccbee7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@megatolya With this change I get the following error:
While hot mw is working perfectly fine with
this.req
&this.res
.Am I missing something? Is it working correctly for you?
1ccbee7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From looking at http://koajs.in/doc/API/context/ it seems that
request
andresponse
are the correct names to use with koa.Perhaps you'll have more luck with https://github.com/leecade/koa-webpack-middleware which appears to be a wrapper around this module by someone who knows koa.
1ccbee7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well,
request
andresponse
are the main Koa objects but they are a different thing fromthis.req
andthis.res
. Indeed, your middleware needs the node response (not Koa enhanced one) andthis.req
/this.res
are the correct object for the task.I commented here to ask how @megatolya made your middleware work, as it does not look possible.
Besides, if we are just supposing that your middleware should work using
this.request
/this.response
, I tell you right now that it is not, so I would revert the commit to restore the correct use with Koa.1ccbee7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in ffbc2d6
1ccbee7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi all!
I found that webpack-hot-middleware can't work with koa. And it should be strongly rewrited to support both frameworks.
1ccbee7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend to not support koa in this package
1ccbee7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😶
Well, that sounds a bit too pessimistic. I have it successfully working in my projects, see https://github.com/albertogasparin/react-starterkit as an example. But I got it working with the "old" code, not with the changes you suggested.
1ccbee7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest update in ffbc2d6 points to what appears to be a maintained wrapper lib by someone who actually uses koa, that's my "official" recommendation at this point - unless someone tells me otherwise.
I don't use koa, so I don't know enough to maintain any kind of support for it.
1ccbee7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sure, good compromise 👍