feat(KB-134): exclude Bun-compiled binaries from npm publish tarball

- Refine files field in cli package.json to use specific globs instead of bare 'dist'
- Include only .js, .d.ts, .d.ts.map, .js.map, and dist/client/** in tarball
- Add tests verifying refined file globs are present
- Add tests ensuring Bun platform binaries are not matched by any glob
- Add changeset for patch release
This commit is contained in:
Dustin Byrne
2026-03-27 19:58:49 -04:00
parent ae90be05e9
commit 28bbcb9fdb
3 changed files with 38 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
---
"@dustinbyrne/kb": patch
---
Exclude Bun-compiled platform binaries from npm publish tarball, reducing package size significantly.

View File

@@ -6,7 +6,11 @@
"kb": "./dist/bin.js"
},
"files": [
"dist",
"dist/**/*.js",
"dist/**/*.d.ts",
"dist/**/*.d.ts.map",
"dist/**/*.js.map",
"dist/client/**",
"README.md"
],
"scripts": {

View File

@@ -24,10 +24,36 @@ describe("CLI package.json publishing config", () => {
expect(pkg.bin.kb).toBe("./dist/bin.js");
});
it('has "files" array that includes "dist"', () => {
it('has "files" array with refined globs for dist output', () => {
expect(pkg.files).toBeDefined();
expect(Array.isArray(pkg.files)).toBe(true);
expect(pkg.files).toContain("dist");
expect(pkg.files).toContain("dist/**/*.js");
expect(pkg.files).toContain("dist/**/*.d.ts");
expect(pkg.files).toContain("dist/**/*.d.ts.map");
expect(pkg.files).toContain("dist/**/*.js.map");
expect(pkg.files).toContain("dist/client/**");
expect(pkg.files).toContain("README.md");
});
it("does not include bare 'dist' entry or globs that would match Bun binaries", () => {
const bunBinaryNames = [
"kb",
"kb-linux-x64",
"kb-linux-arm64",
"kb-darwin-x64",
"kb-darwin-arm64",
"kb-windows-x64.exe",
];
// No bare "dist" entry that would include everything
expect(pkg.files).not.toContain("dist");
// No glob that explicitly targets Bun binaries
for (const entry of pkg.files) {
for (const bin of bunBinaryNames) {
expect(entry).not.toBe(`dist/${bin}`);
}
// No wildcard like "dist/kb*" that would match binaries
expect(entry).not.toMatch(/^dist\/kb/);
}
});
it("is not private", () => {