-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Expose Sockjs server/client #1662
Conversation
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.
Need tests
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.
Also will bee great if you create minimum reproducible test repo with this feature (PoC), it is allow to think about how better solve this
I will add an working example. Just throw this PR together. So I can get feedback :) Will continue tomorrow! :) |
Codecov Report
@@ Coverage Diff @@
## master #1662 +/- ##
=========================================
- Coverage 83.76% 82.87% -0.9%
=========================================
Files 8 8
Lines 536 543 +7
Branches 161 161
=========================================
+ Hits 449 450 +1
- Misses 70 76 +6
Partials 17 17
Continue to review full report at Codecov.
|
@evilebottnawi I've updated the PR now with an example but haven't written any tests. If you think this feature belongs in webpack-dev-server I will add them :) One usecaseAnother usecaseFlowchartTo describe my usecase better I develop cross platform for multiple devices. I use the webpack-dev-server while developing because of the live reloading etc. For production I build with webpack. |
messageQueue.forEach(function dequeue(message) { | ||
sock.send(message); | ||
}); | ||
messageQueue = []; |
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.
Breaking change for multi compiler compilation
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.
Never remove messages, because you can have two/three/four clients, and some clients can have delay
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.
How do you mean? If you lose connection and reconnect you probably don't want to resend all messages again?
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've added the message queue for messages that are sent before the connection is fully established or else you will get an error from sockjs.
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.
@EloB open two or three browsers and tests how it works, we already do same before and remove this, because it is break situation when you have more then one client (some client can disconnect and connect again)
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.
That initSocket
looks really weird in the first place because it's not pure and does side effects on sock
in a recursive fashion.
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.
@evilebottnawi Maybe we could rewrite that initSocket
to be pure instead?
Not sure it is right solution:
We should export this function or use Maybe we can search other solution for this case? Code really looks very misleading. /cc @hiroppy what do you think |
The reason why I did this is because you use
|
More feedback? :) Sorry for pushing but really want this feature :) |
I like export style. |
@hiroppy So you use it like this in your app/devtools? import { send, listen } from 'webpack-dev-server'; My concern about that is that That was one of the reason why I wrote send/listen with es5 code. |
I'm blocked the moment and in need some feedback on my questions :) |
I'm sorry for pushing but I really want this feature. Please give me more feedback so I continue working with this :) |
/cc @hiroppy |
@EloB Sorry for late to my reply. I do not think that BTW, I also apologize for having suggested without thinking about I think this solution is good. |
/cc @EloB we should implement this for all clients https://github.com/webpack/webpack-dev-server/tree/master/client-src |
@hiroppy another solution is to add another file called for instance browser.js and add client methods there ( Then if something adds like to their entry: import { send, listen } from 'webpack-dev-server';
// Then ./lib/browser.js will resolve for web builds |
I been a bit inactive. This is still on my agenda to complete but have a lot to do at the moment. |
Still on my agenda but no time atm. |
Need rebase |
Close in favor #1860, sorry for delay, it will be implemented in next major release |
@evilebottnawi Is there any example how to make something like this with the solution you guys went with? |
@EloB sorry, lost the idea, what you want to achieve? |
@evilebottnawi Be able to use the websocket within webpack dev server to send and receive data. Everything is already well described in this PR comments. There is also example in the PR and images showing it. #1662 (comment) |
With v4 you can do it |
Can you pinpoint me in a direction? |
It is not fully implemented yet, feel free to ping me when we do stable release and I will help you |
For Bugs and Features; did you add new tests?
Not yet this is just a draft.
Motivation / Use-Case
Read more #1661 and #1662 (comment).
Breaking Changes
No
Additional Info
This is just a draft.
webpack.config.js
/some/entry.js