Skip to content

Commit

Permalink
Export TS types in a separate entry point via 'mediasoup-client/types'
Browse files Browse the repository at this point in the history
## Details

The idea is that, instead of exporting types like this:

```ts
import { types as mediasoupClientTypes } from 'mediasoup-client';
```

We import them this way:

```ts
import types as mediasoupClientTypes from 'mediasoup-client/types';
```

## TODO 1

I've briefly tested this and it looks like for this to work, the parent application must have in its `tsconfig.json`:

```
"module": "nodenext",
"moduleResolution": "nodenext",
```

Is this ok? Any other implications?

## TODO 2

Should we stop exporting `types` from 'mediasoup-client' and instead force applications to import them from 'mediasoup-client/types'?

## TODO 3

We should export `HandlerInterface` type so applications do not need to do this ugly thing:

```ts
import { HandlerFactory as MediasoupClientHandlerFactory } from 'mediasoup-client/lib/handlers/HandlerInterface';
```
  • Loading branch information
ibc committed Oct 10, 2024
1 parent 013cc27 commit 0248804
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,21 @@
"type": "opencollective",
"url": "https://opencollective.com/mediasoup"
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"exports": {
".": {
"import": "./lib/index.js",
"types": "./lib/index.d.ts"
},
"./types": {
"import": "./lib/types.js",
"types": "./lib/types.d.ts"
}
},
"files": [
"npm-scripts.mjs",
"lib"
"./npm-scripts.mjs",
"./lib"
],
"engines": {
"node": ">=18"
Expand Down

0 comments on commit 0248804

Please sign in to comment.