Skip to content

Commit 609d6ab

Browse files
committed
maint: Support CommonJS
1 parent 771314f commit 609d6ab

32 files changed

+1915
-237
lines changed
File renamed without changes.

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Ci
1+
name: CI
22

33
on:
44
pull_request:
@@ -55,5 +55,9 @@ jobs:
5555
cache: 'pnpm'
5656
- name: Install dependencies
5757
run: pnpm install
58-
- name: Run Tests
58+
- name: Build
59+
run: pnpm build
60+
- name: Run ESM Tests
5961
run: pnpm test
62+
- name: Run CommonJS Tests
63+
run: pnpm test:commonjs
File renamed without changes.

jest.config.cjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
testEnvironment: 'node',
3+
testMatch: ['**/?(*.)+(test).cjs'],
4+
transform: {},
5+
};

package.json

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,34 @@
22
"name": "token.js",
33
"version": "0.0.2",
44
"description": "Integrate 9 LLM providers with a single Typescript SDK using OpenAIs format.",
5-
"main": "dist/index",
6-
"types": "dist/index",
5+
"main": "dist/index.cjs",
6+
"module": "dist/index.js",
7+
"type": "module",
8+
"exports": {
9+
".": {
10+
"import": "./dist/index.js",
11+
"require": "./dist/index.cjs",
12+
"types": "./dist/index.d.ts"
13+
}
14+
},
715
"files": [
816
"dist/*"
917
],
1018
"scripts": {
11-
"test": "vitest --exclude 'test/manual/**'",
12-
"test:coverage": "vitest --exclude 'test/manual/**' run --coverage",
13-
"test:ui": "vitest --exclude 'test/manual/**' --ui",
14-
"test:manual": "vitest test/manual --testTimeout 100000",
19+
"test": "vitest --dir test/automated",
20+
"test:coverage": "vitest --dir test/automated run --coverage",
21+
"test:ui": "vitest --dir test/automated --ui",
22+
"test:manual": "vitest --dir test/manual --testTimeout 100000",
23+
"test:commonjs": "jest 'test/commonjs/index.test.cjs'",
1524
"lint": "pnpm lint:fix && pnpm lint:check",
1625
"lint:fix": "pnpm lint:check --fix",
1726
"lint:check": "eslint . --max-warnings=0",
1827
"format": "prettier --write .",
19-
"build": "tsc -p ./tsconfig.json",
28+
"build:tsc": "pnpm tsc -p tsconfig.json",
29+
"build": "vite-node ./scripts/build.ts && pnpm build:tsc",
2030
"docs:update": "vite-node ./scripts/docs/generate.ts",
21-
"docs:check": "vite-node ./scripts/docs/check.ts"
31+
"docs:check": "vite-node ./scripts/docs/check.ts",
32+
"clean": "rimraf dist/ ./tsconfig.tsbuildinfo"
2233
},
2334
"author": "Sam Goldman",
2435
"keywords": [],
@@ -31,7 +42,6 @@
3142
"axios": "^1.7.2",
3243
"chalk": "^4.1.2",
3344
"cohere-ai": "^7.10.6",
34-
"groq-sdk": "^0.5.0",
3545
"mime-types": "^2.1.35",
3646
"nanoid": "^5.0.7",
3747
"openai": "^4.52.2"
@@ -44,6 +54,7 @@
4454
"@vitest/coverage-v8": "^2.0.1",
4555
"@vitest/ui": "^2.0.1",
4656
"dotenv": "^16.4.5",
57+
"esbuild": "^0.23.0",
4758
"eslint": "^8.16.0",
4859
"eslint-config-prettier": "^8.3.0",
4960
"eslint-config-standard": "^16.0.3",
@@ -56,6 +67,7 @@
5667
"eslint-plugin-promise": "^5.1.0",
5768
"eslint-plugin-react": "^7.24.0",
5869
"eslint-plugin-unicorn": "^42.0.0",
70+
"jest": "^29.7.0",
5971
"markdown-table": "^3.0.3",
6072
"prettier": "^2.3.1",
6173
"typescript": "^5.5.3",

0 commit comments

Comments
 (0)