Skip to content

Commit cf80abf

Browse files
mquandalleantfu
andauthored
feat: add bun package manager support (#136)
Co-authored-by: Anthony Fu <github@antfu.me>
1 parent 0818874 commit cf80abf

File tree

15 files changed

+678
-4
lines changed

15 files changed

+678
-4
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,19 @@ Visualize your node_modules, inspect dependencies, and more.
1212

1313
### Quick Start
1414

15-
Try it by running following command under your `pnpm`/`npm` project.
15+
Try it by running following command under your `pnpm`/`npm`/`bun` project.
1616

1717
```bash
1818
pnpx node-modules-inspector
1919
```
2020
```bash
2121
npx node-modules-inspector
2222
```
23+
```bash
24+
bunx node-modules-inspector
25+
```
2326

24-
> Currently only support `pnpm` and `npm` projects. We are counting on the community to bring support for other package managers.
27+
> Currently supports `pnpm`, `npm`, and `bun` projects. We are counting on the community to bring support for other package managers.
2528
2629
### Online Version
2730

@@ -61,6 +64,9 @@ pnpx node-modules-inspector build
6164
```bash
6265
npx node-modules-inspector build
6366
```
67+
```bash
68+
bunx node-modules-inspector build
69+
```
6470

6571
Then you can host the `.node-modules-inspector` folder with any static file server.
6672

eslint.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ export default antfu({
1212
'no-console': 'off',
1313
},
1414
})
15+
.append({
16+
files: ['packages/node-modules-tools/test/bun/fixtures/**/package.json'],
17+
rules: {
18+
'pnpm/json-valid-catalog': 'off',
19+
},
20+
})
1521
.append({
1622
files: ['pnpm-workspace.yaml'],
1723
name: 'antfu/yaml/pnpm-workspace',

packages/node-modules-inspector/src/app/components/report/MultipleVersions.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,19 @@ function showGraph(pkgs: PackageNode[]) {
3636
Multi-Versions Packages
3737
<DisplayNumberBadge :number="sorted.length" rounded-full text-sm />
3838
</UiSubTitle>
39-
<div badge-color-primary flex="~ gap-2 items-center" rounded-lg p2 my2 px3>
39+
<!-- Bun does not provide a `bun dedupe` command yet: https://github.com/oven-sh/bun/issues/1343 -->
40+
<div
41+
v-if="rawPayload?.packageManager !== 'bun'"
42+
badge-color-primary
43+
flex="~ gap-2 items-center"
44+
rounded-lg p2 my2 px3
45+
>
4046
<div i-ph-lightbulb-duotone flex-none />
41-
<span>Run <code color-active bg-primary:10 rounded px1 py0.5>{{ rawPayload?.packageManager }} dedupe</code> to de-duplicate packages that satisfies with the ranges</span>
47+
<span>
48+
Run
49+
<code color-active bg-primary:10 rounded px1 py0.5>{{ rawPayload?.packageManager }} dedupe</code>
50+
to de-duplicate packages that satisfies with the ranges
51+
</span>
4252
</div>
4353
<div grid="~ cols-minmax-200px gap-4">
4454
<div

packages/node-modules-tools/src/agent-entry/list.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export async function listPackageDependenciesRaw(
1515
result = await import('../agents/pnpm').then(r => r.listPackageDependencies(options))
1616
else if (manager === 'npm')
1717
result = await import('../agents/npm').then(r => r.listPackageDependencies(options))
18+
else if (manager === 'bun')
19+
result = await import('../agents/bun').then(r => r.listPackageDependencies(options))
1820
else
1921
throw new Error(`Package manager ${manager} is not yet supported`)
2022

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { listPackageDependencies } from './list'

0 commit comments

Comments
 (0)