-
Notifications
You must be signed in to change notification settings - Fork 97
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
rsocket-js can not work in browser #195
Comments
Hi @sudongyuer , Can you provide any more details about what build tooling/versions you are working with? For instance, are you using Webpack, Browserify, or something else? I was able to create a minimal proof of concept using the current version of Working example with CRA, for reference: https://github.com/viglucci/rsocket-js-examples/tree/main/examples/create-react-app |
Thanks for your reply, i think you should remove hasBufferModule code, because i saw so many issue about this problem,and i remove hasBufferModule code, it works(so many project use vite), user don't need to care about this problem, makes it works is very improtant |
Thanks for the additional information. I don't use Vue much and haven't used Vite at all, so I'll need to look a bit more into this, and experiment with RSocket-JS + Vite to see what the best solution could be for this. |
OK peace and love🥶 |
@sudongyuer I was able to get this working in Vite by providing configuration for a polyfill for Buffer using Can you please give this a try in your project and let us know how it works for you? npm i buffer // vite.config.js
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
fallback: {
'buffer': require.resolve('buffer/')
// ^--- provide buffer polyfill
}
},
plugins: [
vue()
]
}) {
"name": "my-vue-app",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"serve": "vite preview"
},
"dependencies": {
"buffer": "^6.0.3",
"rsocket-core": "0.0.27",
"rsocket-websocket-client": "0.0.27",
"vue": "^3.2.16"
},
"devDependencies": {
"@vitejs/plugin-vue": "^1.9.3",
"vite": "^2.6.4"
}
} |
A full working example can be found here: https://github.com/viglucci/rsocket-js-examples/tree/main/examples/vite-vue |
Thanks very much~It works ,but i think it's not the best way to resolve it,should resolve it in this libary,what do you think about |
Thanks for confirming the workaround. For a long-term fix: we are working on a pretty substantial rewrite in #158, where we are also looking to improve compatibility in browser environments. Because of that, and the available workaround, I don't think there will be much need or appetite to address this in the current version. I would recommend closing #196 in favor of our planned improvements in #158, and leveraging the workaround in the meantime if possible. |
Fixes rsocket#195 Signed-off-by: Artur Signell <[email protected]>
rsocket-js can not work in borwser
Expected Behavior
Actual Behavior
Steps to Reproduce
Possible Solution
Your Environment
netty
, ...):javar -version
) or Node version (node --version
)):uname -a
):The text was updated successfully, but these errors were encountered: