esbuild-plugin-prunable
v1.0.3
Published
esbuild plugin for finding unused file list
Downloads
5
Maintainers
Readme
esbuild-plugin-prunable
esbuild plugin for extracting unused module
file list
Installation
npm install -D esbuild-plugin-prunable
Usage
import fs from 'fs';
import { build } from 'esbuild';
import extractPrunableFiles from 'esbuild-plugin-prunable';
build({
...options,
plugins: [
extractPrunableFiles('./src', (prunableFiles) => {
// print unused file list in console
console.log(prunableFiles);
// write unused file list in any file
fs.writeFileSync('prunableFiles.json', JSON.stringify(prunableFiles));
/* ex) remove prunable files, ...etc */
})
],
});
Configuration
const extractPrunableFiles: (rootPath: string, callback: (prunableFiles: string[]) => void, options?: {
excludeExp?: RegExp;
tsconfigFileName?: string;
}) => {
name: string;
setup(build: PluginBuild): void;
};
excludeExp
: RegExp for excluding in prunableFilestsconfigFileName
: TypeScript config file name, If you are using a TypeScript config file name other than tsconfig.json, you need that option. (default: 'tsconfig.json')