What Is the Build Process for Supermemory? A Complete Technical Guide

Supermemory uses a Turbo monorepo orchestrated by Bun, where bun run build triggers a cascading build pipeline that compiles TypeScript, bundles the Next.js Web UI, and uploads Sentry source maps.

The build process for Supermemory is defined in the supermemoryai/supermemory repository as a deterministic, cache-aware pipeline designed for a modern TypeScript monorepo. It leverages Turbo for task orchestration and Bun for package management to compile multiple applications—including the Web UI, MCP server, and browser extensions—from a unified workspace structure.

Monorepo Architecture and Build Tools

Turbo Configuration

The build process is centered on the root turbo.json, which defines the task dependency graph. The build task declares "dependsOn": ["^build"], instructing Turbo to construct a topological build order where dependencies compile before dependents. This configuration caches build outputs—specifically .next/** directories for Next.js applications—enabling incremental builds that skip unchanged workspaces.

Package Manager Setup

The root package.json explicitly declares "packageManager": "bun@1.3.4", locking the repository to a specific Bun version. This ensures that bun install resolves and hoists dependencies consistently across the monorepo's shared packages (@repo/*) and applications (apps/*).

Step-by-Step Build Pipeline

1. Dependency Installation

Initialize the workspace by installing all packages in one pass. This command respects the Bun lockfile and populates node_modules across the entire monorepo:

bun install

2. Root Build Orchestration

Execute the full build from the repository root. The package.json defines the entry point as:

"build": "turbo run build"

Running bun run build invokes Turbo, which recursively executes the build script in every workspace that defines one. For example, Turbo will identify that @repo/lib and @repo/validation have no build scripts and skip them, while targeting apps/web and apps/mcp.

3. Individual Application Builds

Each application defines its own build logic. In apps/web/package.json, the Web UI uses Next.js:

"build": "next build"

This command generates static-site pages, serverless functions, and client bundles into the apps/web/.next/ directory. Similarly, other apps in the apps/ directory execute their respective build commands if defined.

4. Post-Build Source Map Upload

After the primary build succeeds, the root package.json automatically triggers a post-build hook:

"postbuild": "bun run sentry:sourcemaps"

This script uploads source maps to Sentry for error tracking, ensuring production stack traces are properly symbolized without requiring manual intervention.

Building Specific Applications

Web UI (Next.js)

To build only the Web UI without triggering the full monorepo pipeline, navigate to the application directory:

cd apps/web
bun run build

This executes next build directly, producing optimized static assets in .next/. Note that this requires shared packages (@repo/ui, @repo/lib) to be available, as the Web UI imports these internal dependencies for components and validation logic.

Cloudflare Workers Packaging

The Web app supports deployment to Cloudflare Workers via opennextjs-cloudflare. The apps/web/package.json includes specialized scripts for this workflow:

"preview": "opennextjs-cloudflare && wrangler dev",
"deploy": "opennextjs-cloudflare && wrangler deploy",
"upload": "opennextjs-cloudflare && wrangler deploy"

These commands transform the Next.js build output into a Cloudflare-compatible format before deployment.

Quality Assurance and Type Safety

Type Checking

Before or after building, validate TypeScript across all workspaces using the Turbo task defined in turbo.json:

bun run check-types

This executes turbo run check-types, which typically runs tsc --noEmit (or the package-specific type-check script) to catch type errors without emitting compiled files.

Linting and Formatting

Enforce code standards using the Biome toolchain. The root package.json provides a unified linting command:

bun run format-lint

This runs biome check --write across the entire repository, auto-fixing formatting and lint violations in shared packages and applications alike.

Summary

  • The build process for Supermemory is orchestrated by Turbo with Bun as the package manager, defined in the root package.json and turbo.json
  • Running bun run build executes turbo run build, which respects dependency graphs (^build) and caches outputs like .next/**
  • The Web UI in apps/web/ compiles using next build, producing static assets suitable for Vercel or Cloudflare Workers
  • Sentry source maps upload automatically via the postbuild hook in the root configuration
  • Separate Turbo tasks for check-types and format-lint ensure type safety and code quality without blocking the production build

Frequently Asked Questions

What package manager does Supermemory use?

Supermemory uses Bun version 1.3.4 as its package manager, specified in the root package.json under the "packageManager" field. This ensures that all dependency installation and script execution use Bun's native runtime and lockfile for consistent, fast builds across development environments.

How does Turbo handle build dependencies in the monorepo?

According to the turbo.json configuration, the build task declares a dependency on "^build", which tells Turbo to build all workspace dependencies before building the current package. This creates a deterministic, topologically sorted build order where shared packages compile first, and Turbo caches the resulting .next/** directories to skip redundant work in subsequent runs.

Can I build only the Web UI without compiling the entire monorepo?

Yes. Navigate to apps/web/ and run bun run build to execute next build directly for the Web UI only. This bypasses the full monorepo build but requires that shared packages (@repo/*) already be built or available, as the Web UI depends on them for reusable UI components and validation logic.

How are source maps handled during the build process?

After the root build completes successfully, the postbuild script in the root package.json automatically runs bun run sentry:sourcemaps. This uploads source maps to Sentry for error tracking, ensuring that production stack traces in the Web UI and other applications are properly symbolized without requiring manual file uploads.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →