I already used mediasoup-client
with JS and it worked fine.
Now I’m transitioning to TypeScript and am currently using browserify
as my bundler, but I’m not set on it and would probably prefer snowpack
if possible.
Unfortunately I was unable to find any TypeScript mediasoup-client
examples.
How would I import mediasoup-client
properly given these requirements?
- Actually transpiles (no errors)
- Type hints in the IDE
- Import classes separately (
new Device()
instead ofnew mediasoup.Device()
)
The documentation does not match these requirements, so I’ve tried the following variants:
import {DataConsumer} from 'mediasoup-client'
import {DataConsumer} from 'mediasoup-client/src/types'
import {DataConsumer} from 'mediasoup-client/src/DataConsumer'
import {DataConsumer} from 'mediasoup-client/lib/DataConsumer'
And errors ranged from
SyntaxError: ‘import’ and ‘export’ may appear only with ‘sourceType: module’
to
Error TS2305: Module ‘“./node_modules/mediasoup-client/lib”’ has no exported member ‘DataConsumer’
and
[snowpack] Package “mediasoup-client/src/DataConsumer” not found. Have you installed it?
Regarding snowpack
: Is mediasoup-client
an ES-Module?
Ideally I would like to bundle mediasoup-client
separately from my package, but for now I only want it to work at all.