-
-
Notifications
You must be signed in to change notification settings - Fork 535
chore: exclude more files into npm #1252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThe Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.npmignore (1)
45-47
:❓ Verification inconclusive
Overly broad ignore patterns; prefer a whitelist approach
- The pattern
.*
will exclude all hidden files (e.g.,.gitignore
,.npmrc
,.prettierrc
), which risks omitting files you actually want in the package.- While explicitly ignoring
beta-release.js
andtsconfig.json
is fine, maintaining afiles
array in package.json to whitelist only the distribution files (e.g.,dist/
,lib/
,README.md
,LICENSE
) is more robust and easier to maintain.Example diff to narrow patterns if you stick with
.npmignore
:- .* + beta-release.js + tsconfig.json + .eslintrc + .prettierrc + .babelrcYou can also add to package.json:
{ // … "files": [ "dist/", "lib/", "README.md", "LICENSE" ] }And verify the published contents:
🏁 Script executed:
#!/usr/bin/env bash # Verify npm package contents npm pack --dry-run > /tmp/npm-pack.txt # Fail if unwanted configs are present grep -E 'beta-release\\.js|tsconfig\\.json|\\..*rc' /tmp/npm-pack.txt \ && { echo "🚨 Unwanted configs still in package"; exit 1; } \ || echo "✅ Package contents look clean"Length of output: 418
Overly broad ignore patterns; prefer a whitelist approach
The
.*
entry in.npmignore
will drop all hidden files (e.g..gitignore
,.npmrc
,.prettierrc
)—you’ll likely want some of those. Rather than trying to enumerate every dotfile to keep, use afiles
array in package.json to explicitly whitelist what should go into your package. If you still want to narrow your.npmignore
, here’s an example:• Remove the catch-all
.*
• Either list only the few configs you truly want to ignore
• Or switch entirely to a whitelist in package.jsonExample diff for
.npmignore
if you stick with it:- .* + beta-release.js + tsconfig.json + .eslintrc + .prettierrc + .babelrcAdd to package.json:
{ // … "files": [ "dist/", "lib/", "README.md", "LICENSE" ] }And verify your published contents (skipping lifecycle scripts to avoid the husky install error):
#!/usr/bin/env bash npm pack --dry-run --ignore-scripts > /tmp/npm-pack.txt grep -E 'beta-release\.js|tsconfig\.json|\..*rc' /tmp/npm-pack.txt \ && { echo "🚨 Unwanted configs still in package"; exit 1; } \ || echo "✅ Package contents look clean"
I believe these files are included into npm unexpectedly.
Actually we can/should use
files
field instead to include explicit files we want to be included.Summary by CodeRabbit