6.0.9 • Published 1 year ago

resolve-dependencies v6.0.9

Weekly downloads
6,671
License
MIT
Repository
github
Last release
1 year ago

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.
6.0.9

1 year ago

6.0.8

2 years ago

6.0.7

3 years ago

6.0.6

3 years ago

6.0.5

3 years ago

6.0.4

3 years ago

6.0.3

3 years ago

6.0.1

4 years ago

6.0.2

4 years ago

6.0.0

4 years ago

5.1.3

4 years ago

4.2.5

4 years ago

5.1.2

4 years ago

5.1.1

4 years ago

5.1.0

4 years ago

4.2.4

4 years ago

4.2.3

4 years ago

5.0.0

4 years ago

4.2.2

4 years ago

4.2.1

4 years ago

4.2.0

4 years ago

4.1.0

4 years ago

4.0.0

4 years ago

3.0.3

4 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.2.3

5 years ago

2.2.2

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.2.1-next

6 years ago

1.2.0-next

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago