Skip to content

Commit ba35d6b

Browse files
committed
maint: Minimize bundle size by only distributing as CommonJS
1 parent a8d8cf5 commit ba35d6b

File tree

6 files changed

+23
-14
lines changed

6 files changed

+23
-14
lines changed

.changeset/swift-clocks-ring.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'token.js': minor
3+
---
4+
5+
Minimize bundle size

package.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,7 @@
33
"version": "0.2.3",
44
"description": "Integrate 9 LLM providers with a single Typescript SDK using OpenAIs format.",
55
"main": "dist/index.cjs",
6-
"module": "dist/index.js",
76
"type": "module",
8-
"exports": {
9-
".": {
10-
"import": "./dist/index.js",
11-
"require": "./dist/index.cjs",
12-
"types": "./dist/index.d.ts"
13-
}
14-
},
157
"files": [
168
"dist/*"
179
],

scripts/build.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ const build = async () => {
1212
platform: 'node',
1313
treeShaking: true,
1414
tsconfig: 'tsconfig.json',
15+
external: [
16+
'@anthropic-ai/sdk',
17+
'@aws-sdk/client-bedrock-runtime',
18+
'@google/generative-ai',
19+
'chalk',
20+
'axios',
21+
'cohere-ai',
22+
'mime-types',
23+
'openai',
24+
],
1525
}),
1626
])
1727
}

scripts/example.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const dotenv = require('dotenv')
22

3-
const { TokenJS } = require('./dist/index.cjs')
3+
const { TokenJS } = require('../dist/index.cjs')
44

55
dotenv.config()
66

scripts/example.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as dotenv from 'dotenv'
22
import { OpenAI } from 'openai'
33

4-
import { TokenJS } from '../src'
4+
import { TokenJS } from '../dist/index.cjs'
55
dotenv.config()
66

77
const messages: OpenAI.Chat.Completions.ChatCompletionMessageParam[] = [
@@ -15,15 +15,15 @@ const callLLM = async () => {
1515
const tokenjs = new TokenJS()
1616
const result = await tokenjs.chat.completions.create({
1717
// stream: true,
18-
provider: 'openai',
19-
model: 'gpt-4o',
18+
provider: 'gemini',
19+
model: 'gemini-1.5-pro',
2020
messages,
2121
})
2222

2323
console.log(result.choices)
2424

2525
// for await (const part of result) {
26-
// process.stdout.write(part.choices[0]?.delta?.content || "");
26+
// process.stdout.write(part.choices[0]?.delta?.content || "");
2727
// }
2828
}
2929

tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"sourceMap": true,
77
"esModuleInterop": true,
88
"composite": true,
9-
"declaration": true,
109
"noImplicitAny": false,
1110
"removeComments": true,
1211
"noLib": false,
@@ -19,6 +18,9 @@
1918
"rootDir": "./src",
2019
"outDir": "./dist",
2120
"skipLibCheck": true,
21+
"declaration": true,
22+
"declarationDir": "./dist",
23+
"emitDeclarationOnly": true
2224
},
2325
"exclude": [
2426
"node_modules",

0 commit comments

Comments
 (0)