From 37b910ac94db4cf6217509485c8339e5978d20d7 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Wed, 11 Dec 2024 23:56:14 +0100 Subject: [PATCH 1/5] Fix types export for CJS and build config --- packages/livekit-server-sdk/package.json | 13 +++++++++---- packages/livekit-server-sdk/src/AccessToken.test.ts | 12 ++++++------ packages/livekit-server-sdk/src/grants.test.ts | 4 ++-- tsup.config.ts | 6 +++--- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/packages/livekit-server-sdk/package.json b/packages/livekit-server-sdk/package.json index 181ec7f4..b7feb437 100644 --- a/packages/livekit-server-sdk/package.json +++ b/packages/livekit-server-sdk/package.json @@ -5,15 +5,20 @@ "main": "dist/index.js", "require": "dist/index.cjs", "types": "dist/index.d.ts", - "repository": "git@github.com:livekit/server-sdk-js.git", + "repository": "github:livekit/server-sdk-js", "author": "David Zhao ", "license": "Apache-2.0", "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "require": "./dist/index.cjs" + "import": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "require": { + "types": "./dist/index.d.cts", + "default": "./dist/index.cjs" + } } }, "files": [ diff --git a/packages/livekit-server-sdk/src/AccessToken.test.ts b/packages/livekit-server-sdk/src/AccessToken.test.ts index ba1e353f..c1f7036f 100644 --- a/packages/livekit-server-sdk/src/AccessToken.test.ts +++ b/packages/livekit-server-sdk/src/AccessToken.test.ts @@ -9,8 +9,8 @@ import { } from '@livekit/protocol'; import * as jose from 'jose'; import { describe, expect, it } from 'vitest'; -import { AccessToken, TokenVerifier } from './AccessToken'; -import type { ClaimGrants } from './grants'; +import { AccessToken, TokenVerifier } from './AccessToken.js'; +import type { ClaimGrants } from './grants.js'; const testApiKey = 'abcdefg'; const testSecret = 'abababa'; @@ -143,10 +143,10 @@ describe('room configuration with agents and egress', () => { expect(decoded.roomConfig?.name).toEqual('test-room'); expect(decoded.roomConfig?.maxParticipants).toEqual(10); expect(decoded.roomConfig?.agents).toHaveLength(2); - expect(decoded.roomConfig?.agents?.[0].agentName).toEqual('agent1'); - expect(decoded.roomConfig?.agents?.[0].metadata).toEqual('metadata-1'); - expect(decoded.roomConfig?.agents?.[1].agentName).toEqual('agent2'); - expect(decoded.roomConfig?.agents?.[1].metadata).toEqual('metadata-2'); + expect(decoded.roomConfig?.agents?.[0]?.agentName).toEqual('agent1'); + expect(decoded.roomConfig?.agents?.[0]?.metadata).toEqual('metadata-1'); + expect(decoded.roomConfig?.agents?.[1]?.agentName).toEqual('agent2'); + expect(decoded.roomConfig?.agents?.[1]?.metadata).toEqual('metadata-2'); expect(decoded.roomConfig?.egress?.room?.roomName).toEqual('test-room'); }); }); diff --git a/packages/livekit-server-sdk/src/grants.test.ts b/packages/livekit-server-sdk/src/grants.test.ts index 2e494b47..912d4cfd 100644 --- a/packages/livekit-server-sdk/src/grants.test.ts +++ b/packages/livekit-server-sdk/src/grants.test.ts @@ -3,8 +3,8 @@ // SPDX-License-Identifier: Apache-2.0 import { TrackSource } from '@livekit/protocol'; import { describe, expect, it } from 'vitest'; -import type { ClaimGrants, VideoGrant } from './grants'; -import { claimsToJwtPayload } from './grants'; +import type { ClaimGrants, VideoGrant } from './grants.js'; +import { claimsToJwtPayload } from './grants.js'; describe('ClaimGrants are parsed correctly', () => { it('parses TrackSource correctly to strings', () => { diff --git a/tsup.config.ts b/tsup.config.ts index d92f937f..dc23a680 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,12 +1,12 @@ -import { Options } from 'tsup'; +import type { Options } from 'tsup'; const defaultOptions: Options = { - entry: ['src/**/*.ts'], + entry: ['src/**/*.ts', '!src/**/*.test.ts'], format: ['cjs', 'esm'], splitting: false, sourcemap: true, // for the type maps to work, we use tsc's declaration-only command - dts: false, + dts: true, clean: true, bundle: false, target: 'node16', From e90e1d1a901af16642e92ab0b95b7884f2deb3a8 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Wed, 11 Dec 2024 23:57:43 +0100 Subject: [PATCH 2/5] remove comment --- tsup.config.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tsup.config.ts b/tsup.config.ts index dc23a680..d7b6b061 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -5,7 +5,6 @@ const defaultOptions: Options = { format: ['cjs', 'esm'], splitting: false, sourcemap: true, - // for the type maps to work, we use tsc's declaration-only command dts: true, clean: true, bundle: false, From f95960231921b2de8ac997a59caeb9ef0762dac6 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Wed, 11 Dec 2024 23:58:17 +0100 Subject: [PATCH 3/5] Create stupid-monkeys-invent.md --- .changeset/stupid-monkeys-invent.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/stupid-monkeys-invent.md diff --git a/.changeset/stupid-monkeys-invent.md b/.changeset/stupid-monkeys-invent.md new file mode 100644 index 00000000..382a6381 --- /dev/null +++ b/.changeset/stupid-monkeys-invent.md @@ -0,0 +1,5 @@ +--- +"livekit-server-sdk": patch +--- + +Fix types export for CJS and build config From fdd1a165625808b5866bbbbd087020ad5d198a72 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Fri, 13 Dec 2024 15:38:38 +0100 Subject: [PATCH 4/5] fix also for node rtc --- packages/livekit-rtc/package.json | 11 ++++++++--- packages/livekit-rtc/rust-sdks | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/livekit-rtc/package.json b/packages/livekit-rtc/package.json index 30a3a0f9..6018f8d5 100644 --- a/packages/livekit-rtc/package.json +++ b/packages/livekit-rtc/package.json @@ -9,9 +9,14 @@ "types": "dist/index.d.ts", "exports": { ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "require": "./dist/index.cjs" + "import": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "require": { + "types": "./dist/index.d.cts", + "default": "./dist/index.cjs" + } } }, "type": "module", diff --git a/packages/livekit-rtc/rust-sdks b/packages/livekit-rtc/rust-sdks index 8cb20245..06997356 160000 --- a/packages/livekit-rtc/rust-sdks +++ b/packages/livekit-rtc/rust-sdks @@ -1 +1 @@ -Subproject commit 8cb20245841442a7a88766a372002f0eccbf0d58 +Subproject commit 06997356c083b01da766c4c93e8c4e8354d871ce From b45ad31797957bf281a2d10b647c1c6a7df5b03d Mon Sep 17 00:00:00 2001 From: lukasIO Date: Mon, 16 Dec 2024 14:49:32 +0100 Subject: [PATCH 5/5] Update stupid-monkeys-invent.md --- .changeset/stupid-monkeys-invent.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.changeset/stupid-monkeys-invent.md b/.changeset/stupid-monkeys-invent.md index 382a6381..e94d85bd 100644 --- a/.changeset/stupid-monkeys-invent.md +++ b/.changeset/stupid-monkeys-invent.md @@ -1,5 +1,6 @@ --- "livekit-server-sdk": patch +"@livekit/rtc-node": patch --- Fix types export for CJS and build config