Skip to content

feat: support Bun as package manager (--bun flag)#1251

Open
jericbas wants to merge 4 commits intomicrosoft:mainfrom
jericbas:feat/add-bun-support
Open

feat: support Bun as package manager (--bun flag)#1251
jericbas wants to merge 4 commits intomicrosoft:mainfrom
jericbas:feat/add-bun-support

Conversation

@jericbas
Copy link
Copy Markdown

@jericbas jericbas commented Mar 7, 2026

Problem

When using Bun (a fast JavaScript tool), vsce fails to package or publish extensions. The problem is in two places:

  1. The prepublish step always uses npm run vscode:prepublish
  2. This fails if npm is not installed, even when the project uses Bun

What happens:

> bun vsce package --no-dependencies
Executing prepublish script 'npm run vscode:prepublish'...
'npm' is not recognized as an internal or external command
ERROR npm failed with exit code 1

Solution

Add Bun support to vsce with new command line options:

  • --bun : Force vsce to use Bun
  • --no-bun : Force vsce to use npm instead of Bun
  • Auto-detect Bun when bun.lock file exists

This makes vsce work with Bun projects without needing npm.

Changes Made

File What changed
src/npm.ts Add detectBun() to find Bun projects. Add getBunDependencies() function
src/main.ts Add --bun and --no-bun options to CLI
src/package.ts Add useBun option. Update prepublish to use bun run
src/publish.ts Add useBun to publish options
src/test/package.test.ts Add test for Bun support

How to Test

# Auto-detect Bun from bun.lock file
vsce package

# Force Bun
vsce package --bun

# Force npm (skip Bun detection)
vsce package --no-bun

# Publish with Bun
vsce publish --bun

All npm and yarn features still work the same as before.

jericbas added 4 commits March 7, 2026 00:18
- Add --bun and --no-bun CLI flags

- Add detectBun() and getBunDependencies() functions

- Update package.ts to handle useBun option

- Bun auto-detected via bun.lock or bun.lockb files
- Update prepublish() to accept useBun parameter

- Use 'bun' as tool when useBun is true

- Import detectBun in package.ts
@jericbas
Copy link
Copy Markdown
Author

jericbas commented Mar 7, 2026

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant