Skip to content

Optimization: Reduce package size by moving MCP to a separate package and using engines instead of peerDependencies for bun #89

@tmvc03

Description

@tmvc03

Hi! First of all, thank you for creating bunqueue. It's an amazing, lightweight alternative for background jobs in Bun.

However, I noticed a significant bundle bloat after installing the package. The size of node_modules expands drastically from 75.8 MB to 223.1 MB upon adding bunqueue.

After looking into the package structure and package.json, I found two areas where we can significantly optimize this.


1. Separate MCP into a standalone package (e.g., @bunqueue/mcp or bunqueue-mcp)

Right now, the core bunqueue package includes Model Context Protocol (MCP) support out of the box. While this is great for AI agent workflows, it forces all standard users to install heavy dependencies that they don't actually need for basic queue functionality.

Specifically, it brings in:

  • @modelcontextprotocol/sdk
  • zod

Proposed Solution:
Extract the MCP server/features into a separate package, for instance, bunqueue-mcp or @bunqueue/mcp.

  • Users who just need a high-performance SQLite queue can install bunqueue (keeping it extremely lightweight).
  • Users building AI agent integrations can install both bunqueue and bunqueue-mcp.

2. Move bun from peerDependencies to engines

Currently, package.json specifies:

"peerDependencies": {
  "bun": "^1.3.9"
}

Using peerDependencies for a runtime like bun is generally considered an anti-pattern in the modern JS ecosystem. It forces package managers (especially npm/pnpm/yarn when used in mixed or transition environments) to perform unnecessary dependency resolution checks or throw warnings/errors during installation.

Proposed Solution:
The correct way to restrict or enforce the runtime environment is to use the engines field:

"engines": {
  "node": ">=... ", // if applicable
  "bun": ">=1.3.9"
}

Benefits

  • Lightweight Footprint: Brings back the "zero-overhead / ultra-fast" promise of the SQLite-backed queue.
  • Better DX: Speeds up CI/CD install times and saves disk space for thousands of developers.
  • Modular Architecture: Easier to maintain and version the MCP integration separately from the core queue logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions