Comments (24)
@mkozjak mongoose handles this situation pretty well without needing to publish the dist. I might be able to put together a PR sometime today.
from rpc-websockets.
@mkozjak I got slammed with some other project work. I'm not sure when I'll have time to get to this, sorry.
from rpc-websockets.
Awesome work, @dstreet! Thanks!
Will wait for @soulhunter1987 to check up on it just in case and publish the update afterwards.
from rpc-websockets.
@dstreet I will publish this release now. If it works for you, I am okay with it.
from rpc-websockets.
@mkozjak Looks like you forgot to rebuild the dist
before publishing to npm. I apologize if this was a miscommunication on my part
from rpc-websockets.
Browser tests should also be included.
#zuul
#saucelabs
from rpc-websockets.
What about this issue? Generally current Client logic is fully appropriate for browser usage. The only main problem, as i see, is uws usage, which must be replaced with native WebSockets for browser.
from rpc-websockets.
Hi, @soulhunter1987!
For the browser we use browserify, which will take care of our client code.
After installing rpc-websockets, you can copy file ./dist/index.browser.js to your frontend code, since browserify bundled the entire library there for you.
An RPCWebSocket class is exposed there for you to use.
This is an example html: https://gist.github.com/mkozjak/fa9296484c40445af516e563c65536bf
Cheers!
from rpc-websockets.
That will do the job but, not very efficiently. It would be good to also allow compiling from source with webpack or some other bundling tools. That would allow to write ES6-style code and then bundle (and may be transpile for old browsers) it as appropriate for the project. Also it would reduce size of resulting bundle, because repeating dependencies would be included only once.
from rpc-websockets.
Automatic updates via npm/yarn are also not available with this approach, because one will need to copy new file to his project's public directory (of course that may be automated, but that's extra work).
from rpc-websockets.
index.browser.js is really HUGE now, because it includes uws (which is not needed there at all), eventemitter and many other libraries, which may already be used in the project.
from rpc-websockets.
Agreed. TBH, I'm not really experienced with bundlers, so could you point me in the right direction with some examples, maybe? Also, PR welcome!
from rpc-websockets.
First of all you need to supply "src" directory in the package along with "dist".
Then one approach is to manually import and pass "transport" object (uws or browser websocket) to Client constructor via dependency injection.
NodeJs usage would look like this then:
import WebSocket from 'uws';
import {Client} from 'rpc-websocket';
connection = new Client(address, options, WebSocket)
connection.call(...)
And browser ES6 code would be:
import {Client, WebSocketWrapper} from 'rpc-websocket';
connection = new Client(address, options, WebSocketWrapper)
connection.call(...)
where "WebSocketWrapper" is your src/lib/client/websocket.browser.js wrapper class.
So with this approach you give users a choice which transport to use. And it would allow usage of any other transport which implements compatible interface.
from rpc-websockets.
If you create a separate branch with this solution implemented - I could try and test it's browser usage.
from rpc-websockets.
@soulhunter1987: Can you please give me an example library/project where both src and dist are shipped and dependencies are handled like described?
from rpc-websockets.
@dstreet: I believe you meant 'src', since the dist directory should definitely be published. :)
from rpc-websockets.
Sorry, let me revise what I said. The src
can be shipped so that clients can bundle and build from source using Browserify or Webpack. dist
would still need to be shipped because of the dependency on Babel.
from rpc-websockets.
Finally got some time to work on this. I'll submit a PR soon.
from rpc-websockets.
Submitted PR #13. @soulhunter1987 can you test this on your end?
from rpc-websockets.
Great, thanks!
from rpc-websockets.
@soulhunter1987 Do you think you'll have time to review this soon? Turns out I need this for a project I'm working on.
from rpc-websockets.
@dstreet I forgot to include the dist directory altogether. It was still in .gitignore.
from rpc-websockets.
@dstreet Published. Can you check on it, please?
from rpc-websockets.
Still broken, but I found where the problem is. commit 2c20ddd reverted the change I had made to the build script
from rpc-websockets.
Related Issues (20)
- Emit event with params HOT 1
- Rpc-websockets on heroku HOT 1
- Publish 7.4.13 to NPM HOT 1
- How to get the Emit response ?
- Dependency Vulnrabilities HOT 3
- Ignore null in result/error HOT 2
- Help! Run ws on the same port as a http Express? HOT 2
- Access connected clients HOT 4
- Is this the proper way to close the socket? HOT 1
- The Map type cannot be returned using the Server registration method HOT 2
- `fn` type bound in `Server.register` might be slightly off HOT 2
- Migrate from request
- Resolve tough-cookie vulnerability
- How to handle exceptions on server? HOT 3
- Q: namespaces HOT 1
- process is hanging after calling client.close HOT 3
- Whether there is an interest in providing an extensible encoder and decoder? HOT 5
- call results in -32602 Invalid params when no params are given cause it sents null HOT 3
- When sents message without params it is ignored HOT 1
- Any reason emit events on namespace level will be broadcasting instead of only to subscribers like on top level HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rpc-websockets.