From 8dccb59f21410c206a88a09694141db91745beca Mon Sep 17 00:00:00 2001 From: margaretjgu Date: Thu, 7 May 2026 14:37:36 -0400 Subject: [PATCH 1/2] chore: reduce npm package size by ~78% (#250) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two targeted changes to cut the published package from 25.8 MB → 5.7 MB unpacked (2.3 MB → 0.9 MB tarball): 1. Remove `src/` from `files[]` The source tree was never needed at runtime; only `dist/` is. This saves the entire 3.3 MB source directory from the tarball. 2. Add `postbuild` script to strip schema declaration artefacts `dist/es/apis/schemas/` contains 48 per-namespace files each compiled as *.d.ts, *.d.ts.map, and *.js.map (~8.3 MB combined). Consumers cannot meaningfully introspect these types (they reference internal Zod generics), so stripping them has no public-API impact. The *.js runtime files are preserved — they are imported lazily by the CLI at command execution time. Before / after (local build): dist/ total: 33 MB → 15 MB (-55%) npm tarball: 2.3 MB → 0.9 MB (-61%) npm unpacked: 25.8 MB → 5.7 MB (-78%) total files: 3710 → 2884 (-826 files) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ae2de96b..41c6426b 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ ], "scripts": { "build": "node --max-old-space-size=6144 node_modules/typescript/bin/tsc -b", + "postbuild": "node -e \"const {unlinkSync,readdirSync}=require('fs'),{join}=require('path'),d='dist/es/apis/schemas';readdirSync(d).filter(f=>/\\.(d\\.ts|d\\.ts\\.map|js\\.map)$/.test(f)).forEach(f=>unlinkSync(join(d,f)))\"", "test": "npm run build && npm run test:unit && npm run test:license", "test:unit": "node --import tsx/esm --test --experimental-test-coverage --test-coverage-lines=90 --test-coverage-branches=90 --test-coverage-functions=90 --test-coverage-include='src/**/*.ts' --test-coverage-include='packages/*/src/**/*.ts' --test-coverage-exclude='src/cloud/apis/**' --test-coverage-exclude='src/es/apis.ts' --test-coverage-exclude='src/es/api-manifest.ts' --test-coverage-exclude='src/es/apis/**' --test-coverage-exclude='src/cloud/apis.ts' --test-coverage-exclude='src/cloud/serverless-apis.ts' --test-coverage-exclude='node_modules/**'", "test:lint": "eslint src packages", @@ -47,7 +48,6 @@ "types": "./dist/cli.d.ts", "files": [ "dist", - "src", "NOTICE.txt" ], "directories": { From f97aa3069728f03ef874d2ea81a5ec6a31276038 Mon Sep 17 00:00:00 2001 From: margaretjgu Date: Fri, 8 May 2026 10:43:55 -0400 Subject: [PATCH 2/2] fix(postbuild): guard against missing dist/es/apis/schemas directory --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 41c6426b..2e3fb019 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ ], "scripts": { "build": "node --max-old-space-size=6144 node_modules/typescript/bin/tsc -b", - "postbuild": "node -e \"const {unlinkSync,readdirSync}=require('fs'),{join}=require('path'),d='dist/es/apis/schemas';readdirSync(d).filter(f=>/\\.(d\\.ts|d\\.ts\\.map|js\\.map)$/.test(f)).forEach(f=>unlinkSync(join(d,f)))\"", + "postbuild": "node -e \"const {unlinkSync,readdirSync,existsSync}=require('fs'),{join}=require('path'),d='dist/es/apis/schemas';if(existsSync(d))readdirSync(d).filter(f=>/\\.(d\\.ts|d\\.ts\\.map|js\\.map)$/.test(f)).forEach(f=>unlinkSync(join(d,f)))\"", "test": "npm run build && npm run test:unit && npm run test:license", "test:unit": "node --import tsx/esm --test --experimental-test-coverage --test-coverage-lines=90 --test-coverage-branches=90 --test-coverage-functions=90 --test-coverage-include='src/**/*.ts' --test-coverage-include='packages/*/src/**/*.ts' --test-coverage-exclude='src/cloud/apis/**' --test-coverage-exclude='src/es/apis.ts' --test-coverage-exclude='src/es/api-manifest.ts' --test-coverage-exclude='src/es/apis/**' --test-coverage-exclude='src/cloud/apis.ts' --test-coverage-exclude='src/cloud/serverless-apis.ts' --test-coverage-exclude='node_modules/**'", "test:lint": "eslint src packages",