diff --git a/.changeset/swift-clocks-ring.md b/.changeset/swift-clocks-ring.md new file mode 100644 index 0000000..16159f0 --- /dev/null +++ b/.changeset/swift-clocks-ring.md @@ -0,0 +1,5 @@ +--- +'token.js': minor +--- + +Minimize bundle size diff --git a/package.json b/package.json index da72630..77883ab 100644 --- a/package.json +++ b/package.json @@ -3,15 +3,7 @@ "version": "0.2.3", "description": "Integrate 9 LLM providers with a single Typescript SDK using OpenAIs format.", "main": "dist/index.cjs", - "module": "dist/index.js", "type": "module", - "exports": { - ".": { - "import": "./dist/index.js", - "require": "./dist/index.cjs", - "types": "./dist/index.d.ts" - } - }, "files": [ "dist/*" ], diff --git a/scripts/build.ts b/scripts/build.ts index 704c087..2bb769c 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -12,6 +12,16 @@ const build = async () => { platform: 'node', treeShaking: true, tsconfig: 'tsconfig.json', + external: [ + '@anthropic-ai/sdk', + '@aws-sdk/client-bedrock-runtime', + '@google/generative-ai', + 'chalk', + 'axios', + 'cohere-ai', + 'mime-types', + 'openai', + ], }), ]) } diff --git a/scripts/example.cjs b/scripts/example.cjs index 03a6125..7e9eb54 100644 --- a/scripts/example.cjs +++ b/scripts/example.cjs @@ -1,6 +1,6 @@ const dotenv = require('dotenv') -const { TokenJS } = require('./dist/index.cjs') +const { TokenJS } = require('../dist/index.cjs') dotenv.config() diff --git a/scripts/example.ts b/scripts/example.ts index 2d46703..7ff9f5f 100644 --- a/scripts/example.ts +++ b/scripts/example.ts @@ -1,7 +1,7 @@ import * as dotenv from 'dotenv' import { OpenAI } from 'openai' -import { TokenJS } from '../src' +import { TokenJS } from '../dist/index.cjs' dotenv.config() const messages: OpenAI.Chat.Completions.ChatCompletionMessageParam[] = [ @@ -15,15 +15,15 @@ const callLLM = async () => { const tokenjs = new TokenJS() const result = await tokenjs.chat.completions.create({ // stream: true, - provider: 'openai', - model: 'gpt-4o', + provider: 'gemini', + model: 'gemini-1.5-pro', messages, }) console.log(result.choices) // for await (const part of result) { - // process.stdout.write(part.choices[0]?.delta?.content || ""); + // process.stdout.write(part.choices[0]?.delta?.content || ""); // } } diff --git a/tsconfig.json b/tsconfig.json index d96b325..897c535 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,6 @@ "sourceMap": true, "esModuleInterop": true, "composite": true, - "declaration": true, "noImplicitAny": false, "removeComments": true, "noLib": false, @@ -19,6 +18,9 @@ "rootDir": "./src", "outDir": "./dist", "skipLibCheck": true, + "declaration": true, + "declarationDir": "./dist", + "emitDeclarationOnly": true }, "exclude": [ "node_modules",