Skip to content

Commit

Permalink
Fix types export for CJS and build config
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasIO committed Dec 11, 2024
1 parent 2471a19 commit 37b910a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
13 changes: 9 additions & 4 deletions packages/livekit-server-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>",
"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": [
Expand Down
12 changes: 6 additions & 6 deletions packages/livekit-server-sdk/src/AccessToken.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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');
});
});
4 changes: 2 additions & 2 deletions packages/livekit-server-sdk/src/grants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
6 changes: 3 additions & 3 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down

0 comments on commit 37b910a

Please sign in to comment.