This repository was archived by the owner on Oct 16, 2026. It is now read-only.
Repository navigation
perf(build): bundle dist with esbuild so installs fetch only native dependencies - #71
Merged
Merged
Conversation
cursor
Bot
force-pushed
the
cursor/esbuild-bundle-009e
branch
from
October 16, 2026 17:08
a56f5b2 to
8efddb3
Compare
Owner
Author
|
bugbot run |
…ependencies dist/ was one file per module plus nine runtime dependencies (47 packages, 38 MB on disk), and a cold `npx @kodycodes/cli` spent most of its 2.5 s downloading them. esbuild now bundles bin.ts and cli.ts with code splitting, so each `await import()` stays its own chunk and a command loads only what it uses, while every pure-JS dependency (MCP SDK, zod, add-mcp, inquirer, chokidar, es-module-lexer, trace-mapping) is compiled in. Only esbuild, @napi-rs/keyring and ps-list, which ship native code or platform binaries, remain dependencies. tsc still emits the declarations behind the package's `exports`. Co-Authored-By: bot_apk <apk@cognition.ai>
cursor
Bot
force-pushed
the
cursor/esbuild-bundle-009e
branch
from
October 16, 2026 17:12
8efddb3 to
2a76fb8
Compare
An error occurred while trying to automatically change base from
cursor/bench-matrix-009e
to
main
October 16, 2026 17:12
kody-bot
marked this pull request as ready for review
October 16, 2026 17:12
Owner
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 2a76fb8. Configure here.
|
🎉 This PR is included in version 1.26.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Retargeted to
mainafter #70 merged. This is decision C from the Devin performance audit.Why: cold
npx @kodycodes/cliis ~2.5 s, and ~1.9 s of that is npm fetching 47 packages / 38 MB, mostly zod (8.4 MB) and the MCP SDK (8 MB) that the CLI imports in two or three commands.What:
npm run buildrunsscripts/build.mjs(esbuild, entriesbin.tsandcli.ts, ESM, code splitting, target node22) and thentsc --emitDeclarationOnlyfor the declarations behind the packageexports. Every pure-JS dependency is bundled and moves todevDependencies;esbuild,@napi-rs/keyringandps-liststay asdependenciesbecause they ship native code or platform binaries;kody:*(resolved by workerd) andmsw(installed into the Kody cache on demand) stay external. Code splitting preserves every lazyawait import()boundary from #31, so--versionstill loads one chunk plus keyring and does not evaluate the SDK. CJS dependencies (mute-stream,@iarna/toml,cli-width) callrequire()for Node builtins, so each output file gets arequirefromcreateRequire;mainFields: ['module', 'main']picks ESM builds for packages withoutexports(jsonc-parser's UMD build otherwise breaks under bundling). No source changes, no CLI flag/output/auth changes, packagebin,main,exportsandfilesunchanged.Results (Devin, Node 24.21): cold npx
--version2.50 s → 1.05 s; cold install 1.85 s → 1.0 s, 38.2 MB / 47 packages → 17.9 MB / 6 packages; warm whoami / search / git-credential ~120 → ~93 ms, dev 154 → 121 ms;--version, status and execute--localunchanged (interleaved A/B within 1 ms). Unpacked tarball grows from 1.39 MB (256 files) to about 3.8 MB (171 files; 1.7 MB of that is source maps for the bundled dependencies).Independently reproduced here (Node 22.14, fresh isolated npm cache, 3 runs):
npx … --versionnpm install--versionstatuswhoamiexecute --local emptynpm run validategreen (388 pass / 1 skip). Smoke-ran every top-level command from built dist and from the packed tarball install. Confirmedmswstill installs on demand for--target mock(intoXDG_CACHE_HOME/kody/deps/msw),kody:*stays unresolved by the bundle, bin/main/exports/files and.d.tsemissions intact.One review point: esbuild's own binary (~10 MB) is now ~55% of the install and cannot be bundled; the only way below ~1 s cold is dropping esbuild from the dependency set, which is a product change (see Devin proposal 2).
Authored by Devin (performance audit v2); applied via
git amwith authorship preserved.Note
Low Risk
Build and packaging only—no
srcchanges—though bundling and a slimmer dependency tree could surface subtle runtime or publish-time issues if not fully covered by tests.Reviewed by Cursor Bugbot for commit 2a76fb8. Bugbot is set up for automated code reviews on this repo. Configure here.