1 | # npm-bundled
|
2 |
|
3 | Run this in a node package, and it'll tell you which things in
|
4 | node_modules are bundledDependencies, or transitive dependencies of
|
5 | bundled dependencies.
|
6 |
|
7 | [![Build Status](https://travis-ci.org/npm/npm-bundled.svg?branch=master)](https://travis-ci.org/npm/npm-bundled)
|
8 |
|
9 | ## USAGE
|
10 |
|
11 | To get the list of deps at the top level that are bundled (or
|
12 | transitive deps of a bundled dep) run this:
|
13 |
|
14 | ```js
|
15 | const bundled = require('npm-bundled')
|
16 |
|
17 | // async version
|
18 | bundled({ path: '/path/to/pkg/defaults/to/cwd'}, (er, list) => {
|
19 | // er means it had an error, which is _hella_ weird
|
20 | // list is a list of package names, like `fooblz` or `@corp/blerg`
|
21 | // the might not all be deps of the top level, because transitives
|
22 | })
|
23 |
|
24 | // async promise version
|
25 | bundled({ path: '/path/to/pkg/defaults/to/cwd'}).then(list => {
|
26 | // so promisey!
|
27 | // actually the callback version returns a promise, too, it just
|
28 | // attaches the supplied callback to the promise
|
29 | })
|
30 |
|
31 | // sync version, throws if there's an error
|
32 | const list = bundled({ path: '/path/to/pkg/defaults/to/cwd'})
|
33 | ```
|
34 |
|
35 | That's basically all you need to know. If you care to dig into it,
|
36 | you can also use the `bundled.Walker` and `bundled.WalkerSync`
|
37 | classes to get fancy.
|
38 |
|
39 | This library does not write anything to the filesystem, but it _may_
|
40 | have undefined behavior if the structure of `node_modules` changes
|
41 | while it's reading deps.
|
42 |
|
43 | All symlinks are followed. This means that it can lead to surprising
|
44 | results if a symlinked bundled dependency has a missing dependency
|
45 | that is satisfied at the top level. Since package creation resolves
|
46 | symlinks as well, this is an edge case where package creation and
|
47 | development environment are not going to be aligned, and is best
|
48 | avoided.
|