GithubHelp home page GithubHelp logo

aral / resolve-dependencies Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nexe/resolve-dependencies

1.0 1.0 0.0 201 KB

Given an entrypoint, get all of the dependencies connected to it.

License: MIT License

TypeScript 100.00%

resolve-dependencies's Introduction

resolve-dependencies

Given an entrypoint, get a map of files, with their contents, description and dependencies.

File processing occurs concurrently in (CPUs - 1) child processes.

Options

A string:

  • an entrypoint to begin traversal from

An object:

  • entries: string[] - a list of entrypoints to traverse, resolved against cwd
  • cwd: string - the base directory that the resolution occurs from
  • loadContent: boolean - indicates that the content should be included int he FileMap (this may be unreasonable for large dependency trees)
  • files: ({ [key: string]: File | null })[] - a cache of already resolved files
  • expand: 'all' | 'none' | 'variable' - how module contexts should be expanded to include extra files

Strings and Objects

  • Strings are treated as entries
  • Objects are merged
import { resolve } from 'resolve-dependencies'

;(async () => {
  const { entries, files } = await resolve('./entry-file.js')
  console.log(entries['./entry-file.js'])
})()
// {
//   absPath: "/path/to/entry-file.js",
//   contents: "console.log('hello world')",
//   variableImports: false,
//   deps: {
//     "./dependency": {
//       absPath: "/path/to/dependency.js"
//       ...
//     },
//     path: null, //node builtin does not resolve
//     mkdirp: {
//       absPath: "/path/to/node_modules/mkdirp/index.js",
//       modulePath: "/path/to/node_modules/mkdirp",
//       package: {
//         name: 'mkdirp'
//         ...
//       }
//     }
//   }
// }
//  `files` is a similar structure to entries, but 
//   is flat and keyed by the file's absolute path.

resolve-dependencies's People

Contributors

calebboyd avatar

Stargazers

 avatar

Watchers

 avatar

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.