-
Notifications
You must be signed in to change notification settings - Fork 272
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
Primus.library() + SockJS client does not work in electron. #590
Comments
This is because Unfortunately I don't remember why it was needed :/ Can't you use the Node.js client? const Primus = require('primus');
const Socket = Primus.createSocket({ transformer: 'sockjs' });
const primus = new Socket(url); |
Electron really has 3 JavaScript environments:
So which environment are we talking about here? In your original issue you described it as "node" but there's different flavors of "node" here. |
This was in the nodejs side of electron - i.e. the main thread (not a renderer/browser). I'm not using the NodeJs client because the dynamic requires do not work with webpack. In most electron projects the main electron thread will not be built with webpack, in those cases the node version would work fine. Unfortunately I have to use webpack to package the main-thread also. |
@MrBlenny did you try excluding the const lib = primus.library(true); // => build for Node.js
fs.writeFileSync(path, lib, 'utf-8'); and use the result with webpack. I didn't try it but theoretically it should work. |
Did you figure this one out? @MrBlenny |
I couldn't get SockJS to work in both environments. I made a few changes to the websockets lib (I forget what) - it works in both environments but of course doesn't have the nice browser fallbacks. https://github.com/stemn/stemn-frontend-shared/blob/master/src/misc/Websocket/primus-websockets2.js |
Version: Latest
Environment:
I'm building the client library using Primus.library() with sockJs as the transformer.
The output does not work in electron. You get the following error:
This corresponds to the following line:
The issue is that both
window
andself
are undefined. There is noelse
case.I've put in
else{g=this}
This seems to fix the issue for now.The text was updated successfully, but these errors were encountered: