chore: reduce npm package size by ~78%#285
Merged
Merged
Conversation
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)
✅MegaLinter analysis: Success
See detailed reports in MegaLinter artifacts MegaLinter is graciously provided by OX Security |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #250.
Summary
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/fromfiles[]The source tree was never needed at runtime — only
dist/is consumed. Removes 3.3 MB from the published package with no functional impact.2.
postbuildscript: strip schema declaration artefactsdist/es/apis/schemas/contains 48 per-namespace files compiled into*.d.ts,*.d.ts.map, and*.js.map(~8.3 MB combined). Consumers cannot meaningfully introspect these types (they reference internal Zod generics and large transitive type closures). Stripping them has no public-API impact.The
*.jsruntime files are preserved — they are imported lazily by the CLI at command execution time.Measurements
dist/totalImplementation
The
postbuildscript runs automatically after everynpm run buildvia npm's lifecycle hooks:This uses only Node.js built-ins (
fs,path) — no extra dev dependencies needed.Checklist
src/fromfiles[]dist/es/apis/schemas/*.d.ts,*.d.ts.map,*.js.mapnpm pack --dry-runshows expected tarball size (0.9 MB)