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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jpmorganchase/depcom

v0.0.5

Published

A Go package that extracts imported dependencies from Javascript / Typescript / CSS source files. It uses concurrency and [internal APIs](https://github.com/ije/esbuild-internal/) from the [Esbuild project](https://esbuild.github.io/) for blazing performa

Downloads

5

Readme

depcom

A Go package that extracts imported dependencies from Javascript / Typescript / CSS source files. It uses concurrency and internal APIs from the Esbuild project for blazing performance.

NPM Package

Installation

npm install depcom --save

or

yarn add depcom

Usage

import { analyzeRuntimeDependencies } from "depcom";

const { ImportArray, Time, FileCount, Logs } = analyzeRuntimeDependencies({
  path: "path/to/package",
  options: {
    match: "**/*.{tsx,jsx,mjs,cjs,ts,js,css}",
    exclude: ["node_modules/**/*"],
  },
});

CLI

Usage

Build

go build

Tests

go test ./...

CLI Options

Match files
  • -d Set a base directory (default: ./)
  • -a Select multiple files using a glob pattern, starting from the base directory (default: **/*.{tsx,jsx,mjs,cjs,ts,js,css})
  • -x Exclude files using a glob pattern, starting from the base directory. This option can be specified multiple times (default: none)

Target files will be matched by evaluating the glob patterns separately, then calculating the difference between the allowed matches and all the excluded ones.

Examples
  • Parse all javascript files in a package, excluding the node_modules directory (note the quotes, to avoid shell globbing):

./depcom -d path/to/package -a "**/*.{tsx,jsx,mjs,cjs,ts,js,css}" -x "node_modules/**/*"

  • Parse all javascript files in a package outside of src that aren't external dependencies (note the double usage of the -x argument):

./depcom -d path/to/package -a "**/*.{tsx,jsx,mjs,cjs,ts,js,css}" -x "node_modules/**/*" -x "src/**/*"

  • Parse all the javascript files in the current directory and subdirectories, recursively

./depcom

Variadic usage

./depcom ../path/to/directory/file1.js ../another/path/to/directory/file1.js

Help

./depcom -h

Supported import statements

Supported file extensions

  • .js - Javascript files. All unrecognized extensions will fall back to .js (so, for example, you can safely pass .mjs or .cjs files to depcom)
  • .ts - Typescript files.
  • .jsx - Javascript files with React JSX code. Please note that a file with extension .js containing JSX code will not be parsed correctly and will terminate parsing at the first JSX expression. This will emit an error in the logs but won't interrupt parsing of the remaining files.
  • .tsx - Typescript files with React JSX code. Please note that a file with extension .ts containing JSX code will not be parsed correctly and will terminate parsing at the first JSX expression. This will emit an error in the logs but won't interrupt parsing of the remaining files.
  • .css - CSS files

Output

Format

  • Time - Time elapsed parsing
  • Logs - Array of logs, grouped by log level
  • ImportArray - An array of all the unique dependencies extracted from the files. No subpaths.
  • FileCount - The number of files processed

Example

json {"Time":"15.961751ms","ImportArray":["rollup-plugin-esbuild","jest-config","react-native-web",...],"Logs":{"Verbose":null,"Debug":["../modular/packages/modular-scripts/src/check/index.ts: This \"import\" expression will not be bundled because the argument is not a string literal\n","../modular/packages/modular-scripts/src/esbuild-scripts/start/index.ts: This call to \"require\" will not be bundled because the argument is not a string literal\n"],"Info":null,"Err":null,"Warning":null},"FileCount":119}