Skip to content
This repository was archived by the owner on Oct 16, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"skills"
],
"scripts": {
"build": "tsc -p tsconfig.build.json",
"build": "node scripts/build.mjs && tsc -p tsconfig.build.json",
"bench": "node scripts/bench.mjs",
"typecheck": "tsc --noEmit",
"test": "tsx --test test/*.test.ts",
Expand Down Expand Up @@ -48,18 +48,18 @@
"access": "public"
},
"dependencies": {
"@inquirer/checkbox": "^5.2.2",
"@jridgewell/trace-mapping": "^0.3.31",
"@modelcontextprotocol/client": "2.0.0",
"@napi-rs/keyring": "^2.1.0",
"add-mcp": "^2.4.0",
"chokidar": "^4.0.3",
"es-module-lexer": "^3.0.3",
"esbuild": "^0.25.12",
"ps-list": "^9.0.0"
},
"devDependencies": {
"@inquirer/checkbox": "^5.2.2",
"@jridgewell/trace-mapping": "^0.3.31",
"@modelcontextprotocol/client": "2.0.0",
"@types/node": "^24.5.2",
"add-mcp": "^2.4.0",
"chokidar": "^4.0.3",
"es-module-lexer": "^3.0.3",
"msw": "3.0.3",
"tsx": "^4.20.5",
"typescript": "^5.9.2"
Expand Down
38 changes: 38 additions & 0 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env node
// Builds dist/ as an esbuild bundle instead of one file per module.
//
// Every pure-JS dependency is bundled, so `npm install @kodycodes/cli` only
// has to fetch the packages that ship native code or platform binaries (the
// `dependencies` in package.json): fewer tarballs and a fraction of the bytes,
// which is most of what a cold `npx @kodycodes/cli` waits on. Code splitting
// keeps every `await import()` in src a separate chunk, so a command still
// loads only what it uses. `kody:*` is resolved by workerd at run time and msw
// is installed into the Kody cache on demand, so both stay unbundled.
//
// CommonJS dependencies call `require()` for Node builtins; an ESM bundle has
// no `require`, so each output file gets one from `createRequire`.
import { rmSync } from 'node:fs'
import { createRequire } from 'node:module'
import { build } from 'esbuild'

const pkg = createRequire(import.meta.url)('../package.json')

rmSync('dist', { recursive: true, force: true })

await build({
entryPoints: ['src/bin.ts', 'src/cli.ts'],
outdir: 'dist',
bundle: true,
splitting: true,
format: 'esm',
platform: 'node',
target: 'node22',
mainFields: ['module', 'main'],
external: [...Object.keys(pkg.dependencies), 'msw', 'kody:*'],
banner: {
js: "import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);",
},
sourcemap: true,
sourcesContent: false,
logLevel: 'warning',
})
6 changes: 3 additions & 3 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false,
"outDir": "dist",
"rootDir": "src",
"emitDeclarationOnly": true,
"declaration": true,
"sourceMap": true
"outDir": "dist",
"rootDir": "src"
},
"include": ["src/**/*.ts"]
}
Loading