chore: allowlist published files via package.json files instead of .npmignore - #214
Merged
Conversation
…pmignore Replaces the .npmignore denylist with an explicit files allowlist, so new top-level files and build output are excluded by default rather than shipped by accident. index.js is covered by npm's implicit main inclusion; index.d.ts is not, so types is listed explicitly. Verified against the published 3.6.0 tarball: index.js, index.d.ts and all 56 lib/ files are unchanged; only .nvmrc, .prettierrc, AGENTS.md, tsconfig.json and scripts/ are dropped.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes npm publishing “fail closed” by switching from a root-level .npmignore denylist to an explicit files allowlist in package.json, reducing the risk of accidentally shipping new top-level dev/config files.
Changes:
- Add a
filesallowlist inpackage.jsonto explicitly publish onlyindex.d.tsandlib/(with npm still including themainentrypoint). - Remove
.npmignore, relying on the allowlist for package contents control.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| package.json | Adds a files allowlist to control what goes into the published tarball. |
| .npmignore | Removes the old denylist now that publishing is governed by package.json#files. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The root .DS_Store was committed to the repository. It never reached the published package, since npm-packlist ignores .DS_Store by default, but it does not belong in git. Untrack it and add it to .gitignore so the Finder files under lib/, test/ and build/ stay out too.
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.
Follow-up to #213. Instead of extending the
.npmignoredenylist every time a new top-level file appears, this switches to an explicitfilesallowlist inpackage.jsonand deletes.npmignore.A denylist fails open: anything new at the root ships unless someone remembers to exclude it. An allowlist fails closed. This repo already demonstrated the problem locally, where an untracked
.claude/settings.local.jsonended up innpm packoutput.index.jsis not listed because npm force-includes themaintarget.index.d.tsis listed because npm does not force-include thetypestarget, onlypackage.json, README, LICENSE,main,browserandbin(see npm-packlistprocessPackage).Effect on the published package
Baseline is the actual published
zigbee-clusters@3.6.0tarball, not a local working tree.lib/filesRemoved:
.nvmrc,.prettierrc,AGENTS.md,tsconfig.json,scripts/generate-types.mts,scripts/template.d.ts.txtAdded: nothing.
The two
scripts/files were already dropped by #213, so the net new change is four dev-only config/doc files.index.js,index.d.ts,README.md,package.jsonand all 56lib/files are the identical set (verified withdiffon the sorted file lists).Verification
index.js,index.d.tsorlib/.zigbee-clusters/…in node-homey-os, node-homey-zigbeedriver or node-homey-zigbee. Third-party Homey apps can still deep-import, which is why all oflib/stays in the allowlist.tsconfig.jsonwas the only removal with any risk. It hasdeclaration: false,skipLibCheck: falseand noinclude, so it is not usable as anextendsbase, andindex.d.tsis an ambientdeclare module "zigbee-clusters"that resolves without it.require('zigbee-clusters')returns all 62 exports, deep imports oflib/clusters/onOffandlib/utilresolve, andtsc --stricton a consumer importing from the package exits 0.npm test92 passing,npm run lintexit 0 on Node 24.Deleting
.npmignoreis behaviour-neutral here: none of its patterns (build,docs,test,scripts,.eslintrc.json,.eslintignore,.editorconfig,.github) match anything insidelib/, and everything else is now excluded by the allowlist.Second commit: stop tracking
.DS_StoreThe root
.DS_Storewas committed to the repository. It never reached the published package, because.DS_Storeis one of npm-packlist's default ignores, but it does not belong in git either. It is now untracked and added to.gitignore, which also covers the Finder files sitting underlib/,test/andbuild/.This does not change the tarball:
npm pack --dry-runis identical before and after, still 60 entries.