npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

esfinder

v0.0.2-alpha.5

Published

A fast and lightweight tool for analyzing module dependencies and finding which files depend on a given module.

Readme

esfinder

npm version npm downloads bundle JSDocs License

English | 简体中文

esfinder is a tool to analyze and resolve file imports and their dependencies in JavaScript and TypeScript projects. It allows you to efficiently track related files based on import paths, supporting both static and dynamic imports.

Installation

npm install esfinder

API Documentation

parseExports(filePath: string): Promise<Set<string>>

Parameters:

  • filePath (string): The absolute or relative path of the file to parse.

Returns:

  • Promise<Set<string>>: A Promise that resolves to a Set of export names found in the given file.

Description:

This function parses the exports of a file, returning a Set of all named and default exports. It caches the results to improve performance for repeated calls on the same file.

getRelatedFiles(files: string[], importsDir: string, extensions: string[] = DEFAULT_EXTENSIONS): Promise<string[]>

Parameters:

  • files (string[]): A list of file paths to check for related imports.
  • importsDir (string): The directory containing files to be checked for imports.
  • extensions (string[]): An optional array of file extensions to resolve. Defaults to ['.js', '.ts', '.jsx', '.tsx', '.mjs', '.cjs'].

Returns:

  • Promise<string[]>: A Promise that resolves to an array of file paths that are related to the given files, based on the imports and exports.

Description:

This function checks all files in the importsDir for import statements and compares them with the given files. It uses cached export data and attempts to resolve paths based on the provided extensions.

Usage Example

import path from 'node:path'
import { getRelatedFiles, parseExports } from 'esfinder'

const files = ['./src/a.js', './src/c.js']
const importsDir = './src/__tests__'

// Pre-cache the export contents of target files
Promise.all(files.map(f => parseExports(path.resolve(f))))
  .then(() => getRelatedFiles(files, importsDir))
  .then(console.log)
  .catch(console.error)

In this example:

  1. The exports of a.js and c.js are cached.
  2. The function getRelatedFiles finds all files in __tests__ that are related to the given files based on their imports.

Contributing

We welcome contributions to improve esfinder. Please fork the repository, create a branch for your feature, and submit a pull request.

Guidelines:

  • Follow the Code of Conduct.
  • Ensure that tests are added for any new features or bug fixes.
  • Update documentation as necessary.

License

MIT License © Sunny-117