clean-package-dot-json

0.0.0-semantic-release • Public • Published

clean-package-dot-json

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-json

Usage

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

  • name
  • version
  • private
  • publishConfig
  • scripts.preinstall
  • scripts.install
  • scripts.postinstall
  • scripts.dependencies
  • files
  • bin
  • browser
  • main
  • man
  • dependencies
  • peerDependencies
  • peerDependenciesMeta
  • bundledDependencies
  • optionalDependencies
  • engines
  • os
  • cpu
  • description
  • keywords
  • author
  • contributors
  • license
  • homepage
  • repository
  • bugs
  • funding

CDNs

Node.js

  • type
  • exports
  • imports

VSCode Extension Manifest

  • sponsor
  • publisher
  • displayName
  • categories
  • galleryBanner
  • preview
  • contributes
  • activationEvents
  • badges
  • markdown
  • qna
  • sponsor
  • extensionPack
  • extensionDependencies
  • extensionKind
  • icon

Angular Package Format

  • fesm2020
  • fesm2015
  • esm2020
  • es2020

TypeScript

  • types
  • typings
  • typesVersions

Bundlers (Webpack, Rollup, esbuild)

Package Sidebar

Install

npm i clean-package-dot-json

Weekly Downloads

1

Version

0.0.0-semantic-release

License

MIT

Unpacked Size

42.9 kB

Total Files

4

Last publish

Collaborators

  • kirandash