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

pulling-deps

v5.0.1

Published

Pull CJS require, AMD define, and ES2015 import JavaScript dependencies

Downloads

1,655

Readme

pulling-deps

Greenkeeper badge Build Status

Pull CJS require, AMD define, as well as ESM dynamic and static imports.

pulling-deps accomplishes this by building and traversing an AST leveraging acorn.

usage

install

npm

npm install pulling-deps

cli

To run the cli command directly in your console, you will need to install pulling-deps globally. Alternatively, you can create npm scripts in your package json, or use npx. Running npm scripts or npx are the preferred methods for using the CLI.

pull-deps which will extract the dependencies in the files you specify

$ pull-deps src/*.js
$ echo "import('./src/index.js')" | pull-deps

pull-vendor which will extract only node module dependencies

$ pull-vendor src/*.js
$ echo "import('./src/index.js')" | pull-vendor

pull-tree which will generate a flat map of all the dependencies

$ pull-tree src/*.js
$ echo "import('./src/index.js')" | pull-tree

api

pullDeps.fromSource

is a method that takes in a JavaScript string source as the first parameter, and an optional object as the second paramter. The second parameter is an object that is pass straight to acorn.

const pullDeps = require('pullig-deps');

// This gets us an object that has a property `dependencies`, which is an array
// of all the dependencies found.
const result = pullDeps.fromSource(`
  import a from "esmdep";
  const b = require("cjsdep");
  import("dynamicESM");
`);

// Print to console the dependencies, which will have `esmdep`, `cjsdep`, and `dynamicESM`.
console.log(result.dependencies);

pullDeps.fromAST

is a method that takes in as its only parameter an AST as created by acorn.

const acorn = require('acorn-dynamic-import/lib/inject').default(require('acorn'));
const pullDeps = require('pulling-deps');

// Walk the AST to get all the dependencies out
const result = pullDeps.fromAST(acorn(`
  import a from "esmdep";
  const b = require("cjsdep");
  import("dynamicESM");
`));

// Print to console the dependencies, which will have `esmdep`, `cjsdep`, and `dynamicESM`.
console.log(result.dependencies);

build

grunt build

test

grunt test

License

MIT