1.0.0 • Published 2 years ago

esbuild-plugin-unused v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

esbuild-plugin-unused

Find unused files in your esbuild project.

Installation

yarn add -D esbuild-plugin-unused
npm i -D esbuild-plugin-unused
pnpm add -D esbuild-plugin-unused

Usage

Add the plugin to your esbuild config.

const unused = require("esbuild-plugin-unused");

require("esbuild").build({
  entryPoints: ["src/"],
  bundle: true,
  outfile: "dist/out.js",
  plugins: [unused()],
})

On build completion, you will get some console output telling you which files in your project are unused.

~/project ❯ pnpm build

> project@1.0.0 build /user/project
> node ./build.js

Found 2 Unused Files
- /user/project/src/unused.js
- /user/project/src/lib/unused.js

This plugin works by finding files that were not used during the onLoad build step.

Options

export interface Options {
  // source file glob expression
  // defaults to src/**/*
  src?: string | string[];
  // Regular expression to filter files on.
  // defaults to `/.*\.(m|c)?(j|t)sx?$/` which should match all JavaScript and TypeScript file extensions
  filter?: RegExp;
}