@@ -51,13 +51,42 @@ DependencyTree("./this-does-not-exist.js", { allowNotFound: true });
51
51
// returns []
52
52
```
53
53
54
- ### ` nodeModuleNamesOnly `
54
+ ### ` nodeModuleNames `
55
55
56
- (Added in v2.0.0) Navigates all the local files and returns a list of unique package names (not file names) required.
56
+ (Added in v2.0.1) Controls whether or not node package names are included in the list of dependencies.
57
+
58
+ * ` nodeModuleNames: "include" ` : included alongside the local JS files.
59
+ * ` nodeModuleNames: "exclude" ` (default): node module package names are excluded.
60
+ * ` nodeModuleNames: "only" ` : only node module package names are returned.
61
+
62
+ ``` js
63
+ // my-file.js:
64
+
65
+ require (" ./my-local-dependency.js" );
66
+ require (" @11ty/eleventy" );
67
+ ```
57
68
58
69
``` js
59
70
const DependencyTree = require (" @11ty/dependency-tree" );
60
71
61
- DependencyTree (" ./this-does-not-exist.js" , { nodeModuleNamesOnly: true });
62
- // returns []
63
- ```
72
+ DependencyTree (" ./my-file.js" );
73
+ // returns ["./my-local-dependency.js"]
74
+
75
+ DependencyTree (" ./my-file.js" , { nodeModuleNames: " exclude" });
76
+ // returns ["./my-local-dependency.js"]
77
+
78
+ DependencyTree (" ./my-file.js" , { nodeModuleNames: " include" });
79
+ // returns ["./my-local-dependency.js", "@11ty/eleventy"]
80
+
81
+ DependencyTree (" ./my-file.js" , { nodeModuleNames: " only" });
82
+ // returns ["@11ty/eleventy"]
83
+ ```
84
+
85
+ #### (Deprecated) ` nodeModuleNamesOnly `
86
+
87
+ (Added in v2.0.0) Changed to use ` nodeModuleNames ` option instead. Backwards compatibility is maintained automatically.
88
+
89
+ * ` nodeModuleNamesOnly: false ` is mapped to ` nodeModuleNames: "exclude" `
90
+ * ` nodeModuleNamesOnly: true ` is mapped to ` nodeModuleNames: "only" `
91
+
92
+ If both ` nodeModuleNamesOnly ` and ` nodeModuleNames ` are included in options, ` nodeModuleNames ` takes precedence.
0 commit comments