Giter Site home page Giter Site logo

jpmorganchase / depcom Goto Github PK

View Code? Open in Web Editor NEW
13.0 6.0 3.0 254 KB

A blazing fast go / npm package that extracts imported dependencies from Javascript / Typescript / CSS source files.

License: Apache License 2.0

Go 64.55% Shell 19.54% TypeScript 6.77% JavaScript 9.15%
javascript npm typescript css dependency-analysis dependency-parser parser

depcom's Introduction

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 @jpmorganchase/depcom --save

or

yarn add @jpmorganchase/depcom

Usage

import { analyzeRuntimeDependencies } from "@jpmorganchase/depcom";

const { ImportArray, Time, FileCount, Logs } = await 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}

depcom's People

Contributors

cristiano-belloni avatar github-actions[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

depcom's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.