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

resolve-dependencies

v6.0.9

Published

<h2 align="center">resolve-dependencies</h2>

Downloads

25,184

Readme


resolve-dependencies is the very originally named bundler for nexe. It wasn't our intention to build a bundler but that is kind of what this is.

Exports

default: resolveSync(options: Options, ...opts: Options[]): Promise<Result>

  • Options: Object | string -- the entry to start from (if string)
    • 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

All options are deeply merged, string options are added as entries

Result returns a Promise of a result object:

  • Result: Object
    • entries: { [key: entry]: File } - all the entries as provided to the resolve method and the tree of connected files
    • files: { [key: absPath]: File } - all resolved files keyed by their absolute path
    • warnings: string[] - an array warnings generated while processing the files

A File has the following shape

  • File: Object -- An object representing a file
    • size: number -- file size of the link or file
    • absPath: string -- absolute path to the file
    • moduleRoot: string | undefined -- Directory containing a modules package.json
    • package: any | undefined
    • deps: { [key: request]: File | null } -- Dependencies identified in the file, keyed by request
    • belongsTo: File | undefined -- The main file of the owning module
    • realSize: number | undefined -- set to the realfile size if the absPath is a symlink
    • realPath: string | undefined -- set to the realpath if the absPath is a symlink
    • contents: string | null
    • contextExpanded: boolean
    • variableImports: boolean

Example:

import resolveDependencies from 'resolve-dependencies'

const { entries, files } = resolveDependencies('./entry-file.js')
console.log(entries['./entry-file.js'])

// {
//   absPath: "/path/to/entry-file.js",
//   contents: "console.log('hello world')",
//   realSize: 26,
//   realPath: "/path/to/entry/lib/file.js"
//   size: 12
//   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.