Skip to content

Commit 3e57767

Browse files
authored
fix: avoid masquerading types as mjs (#425)
1 parent bae12f5 commit 3e57767

File tree

18 files changed

+134
-46
lines changed

18 files changed

+134
-46
lines changed

.changeset/smart-poems-attack.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
"@livekit/agents": patch
3+
"@livekit/agents-plugin-cartesia": patch
4+
"@livekit/agents-plugin-deepgram": patch
5+
"@livekit/agents-plugin-elevenlabs": patch
6+
"@livekit/agents-plugin-livekit": patch
7+
"@livekit/agents-plugin-neuphonic": patch
8+
"@livekit/agents-plugin-openai": patch
9+
"@livekit/agents-plugin-resemble": patch
10+
"@livekit/agents-plugin-silero": patch
11+
"@livekit/agents-plugins-test": patch
12+
---
13+
14+
fix: avoid masquerading types as mjs

agents/package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
"require": "dist/index.cjs",
77
"types": "dist/index.d.ts",
88
"exports": {
9-
".": {
9+
"import": {
1010
"types": "./dist/index.d.ts",
11-
"import": "./dist/index.js",
12-
"require": "./dist/index.cjs"
11+
"default": "./dist/index.js"
12+
},
13+
"require": {
14+
"types": "./index.d.cts",
15+
"default": "./index.cjs"
1316
}
1417
},
1518
"author": "LiveKit",
@@ -22,7 +25,8 @@
2225
"README.md"
2326
],
2427
"scripts": {
25-
"build": "tsup --onSuccess \"tsc --declaration --emitDeclarationOnly\"",
28+
"build": "tsup --onSuccess \"pnpm build:types\"",
29+
"build:types": "tsc --declaration --emitDeclarationOnly && node ../scripts/copyDeclarationOutput.js",
2630
"clean": "rm -rf dist",
2731
"clean:build": "pnpm clean && pnpm build",
2832
"lint": "eslint -f unix \"src/**/*.ts\"",

agents/src/ipc/inference_proc_executor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class InferenceProcExecutor extends SupervisedProc implements InferenceEx
5555
}
5656

5757
createProcess(): ChildProcess {
58-
return fork(new URL(import.meta.resolve('./inference_proc_lazy_main.js')), [
58+
return fork(new URL('./inference_proc_lazy_main.js', import.meta.url), [
5959
JSON.stringify(this.#runners),
6060
]);
6161
}

agents/src/ipc/job_proc_executor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export class JobProcExecutor extends SupervisedProc implements JobExecutor {
6464
}
6565

6666
createProcess(): ChildProcess {
67-
return fork(new URL(import.meta.resolve('./job_proc_lazy_main.js')), [this.#agent]);
67+
return fork(new URL('./job_proc_lazy_main.js', import.meta.url), [this.#agent]);
6868
}
6969

7070
async mainTask(proc: ChildProcess) {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
"turbo": "^1.13.3",
4343
"typedoc": "^0.25.13",
4444
"typescript": "^5.4.5",
45-
"vitest": "^1.6.0"
45+
"vitest": "^1.6.0",
46+
"tsup": "^8.4.0"
4647
},
4748
"packageManager": "[email protected]"
4849
}

plugins/cartesia/package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
"require": "dist/index.cjs",
77
"types": "dist/index.d.ts",
88
"exports": {
9-
".": {
9+
"import": {
1010
"types": "./dist/index.d.ts",
11-
"import": "./dist/index.js",
12-
"require": "./dist/index.cjs"
11+
"default": "./dist/index.js"
12+
},
13+
"require": {
14+
"types": "./dist/index.d.cts",
15+
"default": "./dist/index.cjs"
1316
}
1417
},
1518
"author": "LiveKit",
@@ -22,7 +25,8 @@
2225
"README.md"
2326
],
2427
"scripts": {
25-
"build": "tsup --onSuccess \"tsc --declaration --emitDeclarationOnly\"",
28+
"build": "tsup --onSuccess \"pnpm build:types\"",
29+
"build:types": "tsc --declaration --emitDeclarationOnly && node ../../scripts/copyDeclarationOutput.js",
2630
"clean": "rm -rf dist",
2731
"clean:build": "pnpm clean && pnpm build",
2832
"lint": "eslint -f unix \"src/**/*.{ts,js}\"",

plugins/deepgram/package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
"require": "dist/index.cjs",
77
"types": "dist/index.d.ts",
88
"exports": {
9-
".": {
9+
"import": {
1010
"types": "./dist/index.d.ts",
11-
"import": "./dist/index.js",
12-
"require": "./dist/index.cjs"
11+
"default": "./dist/index.js"
12+
},
13+
"require": {
14+
"types": "./dist/index.d.cts",
15+
"default": "./dist/index.cjs"
1316
}
1417
},
1518
"author": "LiveKit",
@@ -22,7 +25,8 @@
2225
"README.md"
2326
],
2427
"scripts": {
25-
"build": "tsup --onSuccess \"tsc --declaration --emitDeclarationOnly\"",
28+
"build": "tsup --onSuccess \"pnpm build:types\"",
29+
"build:types": "tsc --declaration --emitDeclarationOnly && node ../../scripts/copyDeclarationOutput.js",
2630
"clean": "rm -rf dist",
2731
"clean:build": "pnpm clean && pnpm build",
2832
"lint": "eslint -f unix \"src/**/*.{ts,js}\"",

plugins/elevenlabs/package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
"require": "dist/index.cjs",
77
"types": "dist/index.d.ts",
88
"exports": {
9-
".": {
9+
"import": {
1010
"types": "./dist/index.d.ts",
11-
"import": "./dist/index.js",
12-
"require": "./dist/index.cjs"
11+
"default": "./dist/index.js"
12+
},
13+
"require": {
14+
"types": "./dist/index.d.cts",
15+
"default": "./dist/index.cjs"
1316
}
1417
},
1518
"author": "LiveKit",
@@ -22,7 +25,8 @@
2225
"README.md"
2326
],
2427
"scripts": {
25-
"build": "tsup --onSuccess \"tsc --declaration --emitDeclarationOnly\"",
28+
"build": "tsup --onSuccess \"pnpm build:types\"",
29+
"build:types": "tsc --declaration --emitDeclarationOnly && node ../../scripts/copyDeclarationOutput.js",
2630
"clean": "rm -rf dist",
2731
"clean:build": "pnpm clean && pnpm build",
2832
"lint": "eslint -f unix \"src/**/*.{ts,js}\"",

plugins/livekit/package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
"require": "dist/index.cjs",
77
"types": "dist/index.d.ts",
88
"exports": {
9-
".": {
9+
"import": {
1010
"types": "./dist/index.d.ts",
11-
"import": "./dist/index.js",
12-
"require": "./dist/index.cjs"
11+
"default": "./dist/index.js"
12+
},
13+
"require": {
14+
"types": "./dist/index.d.cts",
15+
"default": "./dist/index.cjs"
1316
}
1417
},
1518
"author": "LiveKit",
@@ -22,7 +25,8 @@
2225
"README.md"
2326
],
2427
"scripts": {
25-
"build": "tsup --onSuccess \"tsc --declaration --emitDeclarationOnly\" && cp src/turn_detector.onnx dist/",
28+
"build": "tsup --onSuccess \"pnpm build:types\" && cp src/turn_detector.onnx dist/",
29+
"build:types": "tsc --declaration --emitDeclarationOnly && node ../../scripts/copyDeclarationOutput.js",
2630
"clean": "rm -rf dist",
2731
"clean:build": "pnpm clean && pnpm build",
2832
"lint": "eslint -f unix \"src/**/*.{ts,js}\"",

plugins/livekit/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ import * as turnDetector from './turn_detector.js';
66

77
InferenceRunner.registerRunner(
88
turnDetector.EOURunner.INFERENCE_METHOD,
9-
import.meta.resolve('./turn_detector.js'),
9+
new URL('./turn_detector.js', import.meta.url).toString(),
1010
);
1111
export { turnDetector };

0 commit comments

Comments
 (0)