Repository navigation
fix: publish only the package's own files - #133
Merged
Merged
Conversation
2.0.0 shipped both CI workflows, tsconfig.json, tsconfig.publish.json, eslint.config.js, setupTests.ts, .nvmrc and a 16kB migration-storybook.log. The cause is that npm ignores .gitignore entirely whenever .npmignore exists, so stray working-directory files were packed even though git ignores them — migration-storybook.log was never tracked at all. A denylist also rots: the .npmignore still listed .circleci and .flowconfig, neither of which exists. Replaced it with a files allowlist, which cannot leak a file nobody listed. npm always adds package.json, README and LICENSE on top. Tarball goes 26 files -> 18. Verified by installing the packed tarball into a clean project on React 19: CJS and ESM entry points both render, the CSS resolves, and dist/index.d.ts is present. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
2.0.0shipped files consumers have no use for:Confirmed against the published tarball, not just locally —
npm pack react-aspect-ratio@2.0.0contains all of the above.Why it happened
Two compounding reasons, both inherent to
.npmignore:.gitignoreentirely once.npmignoreexists.migration-storybook.logwas never tracked by git —.gitignorehas*.log— but npm packs the working directory, so it shipped anyway. Any stray build log or scratch file in a maintainer's checkout at publish time lands in the tarball..npmignorestill listed.circleciand.flowconfig, neither of which has existed for years, while never gaining entries for the workflows, tsconfigs or eslint config added since.The fix
Replaced
.npmignorewith afilesallowlist, which cannot leak a file nobody listed:package.json,README.mdandLICENSEare always included by npm regardless.aspect-ratio.jsis kept because it has been published since 1.x and may be imported directly;theme.css/theme.jsstay excluded, as they were under.npmignore.Tarball goes 26 files → 18, and nothing consumers rely on is dropped.
Verification
Packed the tarball and installed it into a clean project on React 19 — this exercises the real published artifact, not the working tree:
require('react-aspect-ratio')renders<div class="react-aspect-ratio-placeholder" style="--aspect-ratio:(16/9)">x</div>importfromdist/es/index.jsrenders<div class="react-aspect-ratio-placeholder" style="--aspect-ratio:(0.75)">y</div>react-aspect-ratio/aspect-ratio.cssresolvesdist/index.d.tspresentPlus
pnpm run test:ci6/6 andtsc --noEmitclean.Version bumped to
2.0.1so this is publishable as-is — say the word if you would rather batch it with other work and drop the bump.🤖 Generated with Claude Code