Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/itwillwork/dependencies-tree-builder
A package that creates a dependency tree in a future webpack bundle only by package.json.
https://github.com/itwillwork/dependencies-tree-builder
dependencies frontend nodejs webpack
Last synced: 6 days ago
JSON representation
A package that creates a dependency tree in a future webpack bundle only by package.json.
- Host: GitHub
- URL: https://github.com/itwillwork/dependencies-tree-builder
- Owner: itwillwork
- Created: 2019-03-22T19:27:33.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-08-01T11:45:20.000Z (over 3 years ago)
- Last Synced: 2024-09-16T15:42:00.610Z (about 2 months ago)
- Topics: dependencies, frontend, nodejs, webpack
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# dependencies-tree-builder
A package that creates a dependency tree in a future webpack bundle only by package.json.
## How to use
For example, you have `package.json`:
```
{
"name": "demo-project",
"version": "1.0.0",
"dependencies": {
"@nivo/bar": "0.54.0",
"@nivo/core": "0.53.0",
"@nivo/pie": "0.54.0",
"@nivo/stream": "0.54.0"
}
}
```
Use this package:
```javascriptconst buildTreeAsync = require('dependencies-tree-builder');
const packageJson = require('./package.json');const {
tree,
scoupe,
packageCollector,
} = await buildTreeAsync(packageJson);
```
**tree** - full dependencies tree.
In the example above:
```
{
"fullName": "[email protected]",
"name": "demo-project",
"version": "1.0.0",
"usage": [],
"dependencies": [
{
"fullName": "@nivo/[email protected]",
"name": "@nivo/bar",
"version": "0.54.0",
"usage": [
"[email protected]"
],
"dependencies": [
{
"fullName": "@nivo/[email protected]",
"name": "@nivo/axes",
"version": "0.54.0",
"usage": [
"[email protected]",
"@nivo/[email protected]"
],
"dependencies": [
{
"fullName": "@nivo/[email protected]",
"name": "@nivo/core",
"version": "0.54.0",
"usage": [
"[email protected]",
"@nivo/[email protected]",
"@nivo/[email protected]"
],
"dependencies": [
...
}
```
**scoupe** - aggregated tree by package name and version.
In the example above:
```
{
"@nivo/bar": {
"0.54.0": {
"usages": [
[
"[email protected]"
]
],
"version": "0.54.0",
"name": "@nivo/bar",
"tunable": true,
"dedupedUsages": [
[
"[email protected]"
]
],
"countInstances": 1,
"carriers": [
"[email protected]"
],
"popular": true,
"main": true
}
},
"@nivo/axes": {
"0.54.0": {
"usages": [
[
"[email protected]",
"@nivo/[email protected]"
]
...
}
```**packageCollector** - wrap [package-json](https://www.npmjs.com/package/package-json) package with cache, has methods:
* packageCollector.get(name, version) - return package.json for name@version package
* packageCollector.getAllVersions(name) - return all versions of package### Installation
```
npm i --save dependencies-tree-builder
```
## Contributing
Got ideas on how to make this better? Open an issue!## License
MIT