clean-package-dot-json v0.0.0-semantic-release
Clean package.json in prepack hook before publishing your package by removing unnecessary properties.
Feel free to reach me on other social platforms! š YouTube || Discord || Instagram || Twitter || TikTok || Blog || Facebook
š Support
Please āļø star this project and share it with others to show your support. Follow me for updates on future projecs and tutorials! ā¤ļø
Purpose?
package.json most of the time gets filled up with development related information ex: devDependencies and configuration like eslintConfig, prettier, lint-staged, simple-git-hooks, etc.
If you are building npm package or micropackages where every byte matters then you can use clean-package-dot-json in a prepack hook to remove unnecessary properties from package.json.
Install
npm install --save-dev clean-package-dot-jsonUsage
Add clean-package-dot-json to the prepack hook, which runs before npm publish and npm pack.
// package.json
{
name: 'my-package',
// ...
scripts: {
// ...
prepack: 'node ./node_modules/.bin/clean-package-dot-json',
},
}Flags
| Flag | Description |
|---|---|
-i, --ignore <property name> | Property names to ignore during cleanup. Accepts multiple flags or a comma-delimited list. |
-v, --verbose | Verbose logs. |
-d, --dry | Dry run mode. Instead of writing to disk, it will log it. |
Default ignored properties
By default, these properties are ignored in package.json:
npm
nameversionprivatepublishConfigscripts.preinstallscripts.installscripts.postinstallscripts.dependenciesfilesbinbrowsermainmandependenciespeerDependenciespeerDependenciesMetabundledDependenciesoptionalDependenciesenginesoscpudescriptionkeywordsauthorcontributorslicensehomepagerepositorybugsfunding
CDNs
Node.js
typeexportsimports
VSCode Extension Manifest
sponsorpublisherdisplayNamecategoriesgalleryBannerpreviewcontributesactivationEventsbadgesmarkdownqnasponsorextensionPackextensionDependenciesextensionKindicon
Angular Package Format
fesm2020fesm2015esm2020es2020
TypeScript
typestypingstypesVersions
Bundlers (Webpack, Rollup, esbuild)
2 years ago
2 years ago