Skip to main content
This guide provides a detailed look at how individual packages are structured, configured, and built within the Sentry JavaScript SDK monorepo.

Package Anatomy

Every package in the monorepo follows a consistent structure. Let’s examine @sentry/core as an example.

Directory Structure

package.json Configuration

Here’s the package.json for @sentry/core with annotations:

TypeScript Configuration

Main Config (tsconfig.json)

Used for IDE support and linting:

Types Config (tsconfig.types.json)

Used for generating .d.ts files:

Build Configuration

Rollup Config (rollup.npm.config.mjs)

Packages use Rollup for transpilation:
The rollup-utils package in dev-packages/ provides shared Rollup configuration.

Build Process

When you run yarn build:dev in a package:

1. TypeScript Type Generation

Outputs:

2. Downlevel Types for TS 3.8

Outputs:

3. Rollup Transpilation

Outputs:

Package Categories

Core Packages

Minimal dependencies, provide foundation: @sentry/core - Base SDK
  • No external dependencies
  • Provides: Hub, Scope, Client, Integrations
  • Used by: All platform and framework SDKs
@sentry/browser-utils - Browser utilities
  • Dependencies: @sentry/core
  • Provides: DOM utilities, fetch/XHR instrumentation
  • Used by: Browser-based SDKs
@sentry/node-core - Node core
  • Dependencies: @sentry/core
  • Provides: Node.js-specific functionality (without OTel)
  • Used by: @sentry/node and serverless SDKs

Platform SDKs

@sentry/browser
  • Dependencies: @sentry/core, @sentry/browser-utils
  • Provides: Browser SDK, CDN bundles
  • Special build: build:bundle creates CDN bundles
@sentry/node
  • Dependencies: @sentry/core, @sentry/node-core, @sentry/opentelemetry
  • Provides: Node.js SDK with OpenTelemetry instrumentation
  • Includes: HTTP, database, and framework integrations
@sentry/bun
  • Dependencies: @sentry/core, @sentry/node-core
  • Provides: Bun runtime SDK
@sentry/deno
  • Dependencies: @sentry/core, @sentry/browser-utils
  • Provides: Deno runtime SDK
@sentry/cloudflare
  • Dependencies: @sentry/core
  • Provides: Cloudflare Workers SDK
  • Edge runtime compatible

Framework Integrations

@sentry/react
  • Dependencies: @sentry/browser, @sentry/core
  • Provides: Error boundary, hooks, React Router integration
  • Peer dependencies: react
@sentry/nextjs
  • Dependencies: @sentry/node, @sentry/react, @sentry/browser
  • Provides: Next.js SDK with client/server integration
  • Special: Has client, server, and edge entry points
  • Build config: Webpack plugins for instrumentation
@sentry/vue
  • Dependencies: @sentry/browser, @sentry/core
  • Provides: Vue error handler, Vue Router integration
  • Peer dependencies: vue
@sentry/sveltekit
  • Dependencies: @sentry/node, @sentry/svelte, @sentry/browser
  • Provides: SvelteKit SDK with client/server
  • Special: Vite plugins for instrumentation

Special Build Targets

CDN Bundles (Browser Only)

The @sentry/browser package creates CDN bundles:
Outputs:
These are uploaded to https://browser.sentry-cdn.com/.

Lambda Layers (AWS Serverless)

The @sentry/aws-serverless package creates Lambda layers:

Browser Bundles with Integrations

Some bundles include specific integrations pre-configured.

Testing Setup

Vitest Configuration

Packages use Vitest for testing:

Test Structure

Tests mirror the source structure:

Circular Dependency Checking

Each package can check for circular dependencies:
This runs Madge on the package:

Package Dependencies

Internal Dependencies

Use workspace protocol:

External Dependencies

Minimize external dependencies to reduce bundle size:

Peer Dependencies

Framework integrations specify peer dependencies:

Publishing

Packages are published to npm with:
Only the build/ directory is published:

Next Steps