fix(build): reduce published package size by fixing files field#123
Open
Kyzgor wants to merge 1 commit intopermitio:mainfrom
Open
fix(build): reduce published package size by fixing files field#123Kyzgor wants to merge 1 commit intopermitio:mainfrom
Kyzgor wants to merge 1 commit intopermitio:mainfrom
Conversation
The existing `files` field in package.json contained broken negation patterns (`!**/*.spec.*`, `!**/*.json`) that caused the whitelist to not function correctly, and referenced a nonexistent `CHANGELOG.md`. Fix the `files` field to properly scope exclusions within the `build/` directory, removing test artifacts from the published package while keeping the whitelist behavior intact. Fixes permitio#90
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.
Summary
Fix the
filesfield inpackage.jsonso the published npm package only includes necessary files (build/,LICENSE,README.md), excluding source code, docs, config files, lockfiles, and test artifacts.Problem
As reported in #90, the published package contains many unnecessary files —
src/,docs/,.github/,.vscode/,.husky/,imgs/,yarn.lock, and various config files. This drastically increases download/on-disk size and can confuse security tools that scan lockfiles.The root cause: the existing
filesfield uses top-level negation patterns (!**/*.spec.*,!**/*.json) that break the whitelist behavior, and references a nonexistentCHANGELOG.md.Solution
Fixed the
filesfield to properly scope exclusions within thebuild/directory:Changes:
!**/*.spec.*with properly scoped!build/**/*.spec.*!**/*.jsonwith targeted!build/testsexclusionCHANGELOG.mdreferenceTesting
Verified with
npm pack --dry-run --ignore-scripts:src/,docs/,.github/,.vscode/,.husky/,imgs/,yarn.lock, config files (2,374+ files)build/(minus tests),LICENSE,README.md,package.json(1,767 files)src/,docs/, config, or lockfiles in published output*.spec.*) in published outputBackwards Compatibility
No breaking changes. The published package contents are a strict subset of what was previously published — only unnecessary files were removed.
Checklist
yarn lintpassesnpm pack --dry-runsrc/openapi/(auto-generated)Fixes #90