Skip to content

Commit

Permalink
migrate to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
satoren committed Jan 27, 2025
1 parent d84522f commit 1aa723c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions npm-scripts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ function buildTypescript({ force = false } = { force: false }) {

deleteLib();
executeCmd('tsc');
executeCmd('tsc -p ./tsconfig.cjs.json');
}

function lint() {
Expand Down
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,18 @@
"type": "opencollective",
"url": "https://opencollective.com/mediasoup"
},
"main": "lib/index.js",
"main": "lib/cjs/index.js",
"types": "lib/index.d.ts",
"exports": {
".": {
"import": "./lib/index.js",
"require": "./lib/cjs/index.js"
},
"./lib/*": {
"import": "./lib/*.js",
"require": "./lib/cjs/*.js"
}
},
"files": [
"npm-scripts.mjs",
"lib"
Expand Down
23 changes: 23 additions & 0 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compileOnSave": true,
"compilerOptions": {
"lib": ["es2022", "dom"],
"target": "es2020",
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"isolatedModules": true,
"strict": true,
"outDir": "lib/cjs",
"declaration": true,
"declarationMap": true
},
"include": ["src"],
"watchOptions": {
"watchFile": "useFsEvents",
"watchDirectory": "useFsEvents",
"fallbackPolling": "dynamicPriority",
"synchronousWatchDirectory": true
}
}

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"lib": ["es2022", "dom"],
"target": "es2020",
"module": "commonjs",
"module": "ES2015",
"moduleResolution": "node",
"esModuleInterop": true,
"isolatedModules": true,
Expand Down

0 comments on commit 1aa723c

Please sign in to comment.