Comments (5)
How do you bundle your code?
from isomorphic-ws.
@julien-f with Babel and WebPack
Here is my package.json
:
{
"private": true,
"scripts": {
"build": "babel src -d lib; webpack",
"start": "budo dist/index.js:index.js --ssl --cert ... --key ..."
},
"dependencies": {
"isomorphic-ws": "^4.0.1",
"ws": "^7.2.5"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.6",
"@babel/preset-env": "^7.9.6",
"budo": "^11.6.3",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11"
},
"browserslist": "> 0.25%, not dead"
}
from isomorphic-ws.
I suspect that your code is using the Node implementation provided by node.js
instead of the browser implementation provided by browser.js
.
Make sure that your bundler supports the browser
entry in package.json
:
Line 6 in 0a0d169
from isomorphic-ws.
Thank you @julien-f but this doesn't work for me. I tried to call src/index.js
directly bypassing bundlers, but the result is the same. Is there a minimal example working in browser which uses this library? I agree, the issue is quite weird since I don't see any dependencies to satisfy except ws
.
from isomorphic-ws.
In browser, the module should use the code in browser.js
, you can try by directly requiring/importing 'isomorphic-ws/browser.js'
.
This module is automatically selected if the bundler supports the browser
entry in package.json
.
from isomorphic-ws.
Related Issues (20)
- Doesn't work in a react development environment HOT 3
- Error: 'WebSocket': The subprotocol '[object Object]' is invalid.\n at RPC.createSocket HOT 1
- Export ES modules HOT 2
- plans for ws 8.x? HOT 2
- Add support for normal "ws" events HOT 1
- Make export interface for NodeJS and browser the same HOT 2
- It's alive? 😟 HOT 2
- The `ws` module no longer exposes the standard API for onmessage/onclose events HOT 2
- Export ClientOptions from 'ws' HOT 10
- ESM Import Error HOT 7
- Version 5.0.0 fails when used with typescript and karma
- Please export Websocket
- Consider marking the `ws` peer dependency as optional
- Documentation: no Server implementation in browsers. Creating a WebSocket server in the browser is now possible
- vscode extension browser env: r is not a constructor HOT 1
- Export the correct type
- Way to compile without error HOT 4
- LICENSE HOT 1
- TypeScript supporting? HOT 11
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 isomorphic-ws.