Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

next-unused

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-unused

next-unused is an easy way to find unused files in your [Next.js](https://github.com/zeit/next.js) project.

  • 0.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
36K
increased by28.32%
Maintainers
1
Weekly downloads
 
Created
Source

next-unused

next-unused is an easy way to find unused files in your Next.js project.


Installation

Make sure you install as a devDependency, otherwise you will add 60mb+ to your build.

$ yarn add next-unused -D

Usage

In package.json, add a script to find unused files:

"scripts": {
  "find:unused": "next-unused"
}

Run the script to list any unused files: yarn find:unused.


Configuration

Add a property to your package.json to configure next-unused:

{
  "next-unused": {
    "alias": {},
    "include": [],
    "exclude": [],
    "entrypoints": []
  }
}
PropertyTypeDefaultDescription
debugbooleanfalseturn on debug messages
aliasobject{}import aliases in webpack format ({ "@components": "components/" })
includestring[]['pages']list of directories to search through. pages is always included
excludestring[][]array of RegExp that exclude matching filenames
entrypointsstring[]['pages']list of directories to use as entrypoints. pages is always included

Example

Your Next.js setup looks like this:

package.json
├─ pages/
│  ├─ index.js
└─ components/
   ├─ button.js
   └─ image.js

And your pages/index.js contains:

import Button from '../components/button'

export default () => {
  return (
    <Button>Click me</Button>
  )
}

Configure next-unused to include the components directory in package.json:

{
  "next-unused": {
    "include": ["components"]
  }
}

Running next-unused will output:

Found 1 unused file:
components/image.js

Credits

Shu and Luc wrote the initial version of this script.

  • Shu
  • Luc

FAQs

Package last updated on 17 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc