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

migrate to ESM (To avoid breaking compatibility) #315

Open
wants to merge 3 commits into
base: v3
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
The CJS build will be placed in the same directory as before
satoren committed Jan 28, 2025
commit bf6514dec8594dad48e74505a76a24e5b680afd2
2 changes: 1 addition & 1 deletion npm-scripts.mjs
Original file line number Diff line number Diff line change
@@ -159,7 +159,7 @@ function buildTypescript({ force = false } = { force: false }) {

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

function lint() {
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -16,28 +16,28 @@
"type": "opencollective",
"url": "https://opencollective.com/mediasoup"
},
"main": "lib/cjs/index.js",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"exports": {
".": {
"import": "./lib/index.js",
"require": "./lib/cjs/index.js"
"import": "./lib/esm/index.js",
"require": "./lib/index.js"
},
"./lib/*": {
"import": "./lib/*.js",
"require": "./lib/cjs/*.js"
"import": "./lib/esm/*.js",
"require": "./lib/*.js"
},
"./lib/handlers/*": {
"import": "./lib/handlers/*.js",
"require": "./lib/cjs/handlers/*.js"
"import": "./lib/esm/handlers/*.js",
"require": "./lib/handlers/*.js"
},
"./lib/handlers/ortc/*": {
"import": "./lib/handlers/ortc/*.js",
"require": "./lib/cjs/handlers/ortc/*.js"
"import": "./lib/esm/handlers/ortc/*.js",
"require": "./lib/handlers/ortc/*.js"
},
"./lib/handlers/sdp/*": {
"import": "./lib/handlers/sdp/*.js",
"require": "./lib/cjs/handlers/sdp/*.js"
"import": "./lib/esm/handlers/sdp/*.js",
"require": "./lib/handlers/sdp/*.js"
}
},
"files": [
4 changes: 2 additions & 2 deletions tsconfig.cjs.json → tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -3,12 +3,12 @@
"compilerOptions": {
"lib": ["es2022", "dom"],
"target": "es2020",
"module": "commonjs",
"module": "ES2015",
"moduleResolution": "node",
"esModuleInterop": true,
"isolatedModules": true,
"strict": true,
"outDir": "lib/cjs",
"outDir": "lib/esm",
"declaration": true,
"declarationMap": true
},
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
"compilerOptions": {
"lib": ["es2022", "dom"],
"target": "es2020",
"module": "ES2015",
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"isolatedModules": true,