Skip to content
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

Export TS types in a separate entry point via 'mediasoup-client/types' #308

Draft
wants to merge 4 commits into
base: v3
Choose a base branch
from

Conversation

ibc
Copy link
Member

@ibc ibc commented Oct 10, 2024

Details

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

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

We import them this way:

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

I've also removed "main" and "types" fields in package.json since they are replaced by the new "exports" field.

Related documentation

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:

import { HandlerFactory as MediasoupClientHandlerFactory } from 'mediasoup-client/lib/handlers/HandlerInterface';

ibc added 2 commits October 10, 2024 14:13
## 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';
```
@ibc ibc requested a review from jmillan October 10, 2024 12:16
@jmillan
Copy link
Member

jmillan commented Oct 11, 2024

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",

If the application does not set such values (for any reason they may have), can it still use the old way of importing the types?

@ibc
Copy link
Member Author

ibc commented Oct 11, 2024

I am not sure. I've tried to test using mediasoup-demo client app but it's SUPER OLD and doesn't even use TypeScript so we are lost here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants