Skip to content

Commit 9dd0535

Browse files
committed
ok also allow single entry point
1 parent 4abe50e commit 9dd0535

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ npm install rtp.js
5858
const utils = require('rtp.js/utils');
5959
```
6060

61+
- Single entry point ("main" or "module" entries in `package.json`) is also possible for backwards compatibility:
62+
63+
```ts
64+
// ESM
65+
import { packets, utils } from 'rtp.js';
66+
67+
// CJS
68+
const { packets, utils } = require('rtp.js'=;
69+
```
70+
6171
## Note about TypeScript
6272
6373
**rtp.js** is written in TypeScript with `module: NodeNext`, meaning that TypeScript projects that have **rtp.js** as dependency must have `moduleResolution` with value "node16", 'NodeNext" or "bundler" in their `tsconfig.json` file.

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,16 @@
1212
"type": "git",
1313
"url": "git+https://github.com/versatica/rtp.js.git"
1414
},
15+
"main": "./lib/index.cjs",
16+
"module": "./lib/index.mjs",
17+
"types": "./lib/index.d.mts",
1518
"exports": {
19+
".": {
20+
"typedoc": "./src/index.mts",
21+
"types": "./lib/index.d.mts",
22+
"import": "./lib/index.mjs",
23+
"require": "./lib/index.cjs"
24+
},
1625
"./packets": {
1726
"typedoc": "./src/packets/public.mts",
1827
"types": "./lib/packets/public.d.mts",

src/index.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * as packets from './packets/public.mts';
2+
export * as utils from './utils/public.mts';

0 commit comments

Comments
 (0)