Open artdevgame opened 4 years ago
bump
@artdevgame as a workaround you can do the following:
Add exports-loader
to your's webpack-config:
...
rules: [
...,
{
test: require.resolve('obs-websocket-js/dist/obs-websocket'),
use: 'exports-loader?OBSWebSocket'
},
...
]
...
After that you can
import OBSWebSocket from 'obs-websocket-js/dist/obs-websocket';
var obs = new OBSWebSocket();
as usual.
P.S. original answer: https://stackoverflow.com/a/51360811
Hi, I hope that this issue is the relevant place to ask. I have a project in Angular and I try to add this library.
I success to import the lib with:
import OBSWebSocket from 'obs-websocket-js/dist/obs-websocket';
but then I cannot use all the plus of typescript because the folder of the types is 2 levels above (same level as dist
).
How could I enjoy both worlds?
Hey there!
The issue is no more actual since maintainers added a native support for UMD modules: https://github.com/haganbmj/obs-websocket-js/commit/1f7f9f45cfc738e040ad0ce5457c126501c8ec08
Anyone who's on the boat should update to obs-websocket-js@4
@hodbauer Since support for UMD is here you can now just
import OBSWebSocket from 'obs-websocket-js';
const ws = new OBSWebSocket()
ws.connect <- IDE TS autocompletion
Description:
I'm trying to use this library in the browser and I'd like to include the dist files with an ES6 import, i.e.:
But I'm experiencing a problem with how
OBSWebSocket
is exported. Currently the dist/obs-websocket.js has the following:This results in an empty object (
{}
).If I change the line to read:
I get the result I desire, which is access to the OBSWebSocket constructor.
Is there any reason the dist file can't be updated?
Versions Used (if applicable):