Development Builds
Build All Packages
For development, use thebuild:dev command which runs transpilation and type generation:
build:transpile- Transpiles TypeScript to JavaScript (ESM and CJS)build:types- Generates TypeScript type definitions
Build in Watch Mode
For active development, use watch mode to automatically rebuild on file changes:Build a Single Package
To build only a specific package and its dependencies:- The
@sentry/reactpackage - All of its dependencies (
@sentry/browser,@sentry/core,@sentry/utils, etc.) - All packages that depend on it (
@sentry/gatsby,@sentry/nextjs, etc.)
Build from a Package Directory
You can also build from within a specific package directory:Production Builds
Full Production Build
For a complete production build:package.json:
- Package version verification
- Transpilation (
build:transpile) - Type generation (
build:types) - Browser bundles (
build:bundle) - Lambda layers (
build:layer)
Browser Bundles Only
To build only the browser bundles (CDN files):packages/browser/build/bundles/.
There are no guarantees about the produced file names, so make sure to check which files are generated after upgrading.
Build Tarballs for Publishing
To create npm tarballs for testing or publishing:.tgz files in each package directory that can be:
- Installed with
yarn add ./path/to/package.tgz - Used in E2E tests with Verdaccio
- Tested before publishing to npm
Understanding Build Outputs
Package Build Structure
After building, each package has the following structure:Nx Build Targets
The build system is configured innx.json with specific targets and dependencies:
^ prefix means “this target’s dependencies from upstream packages.”
Build Caching
Nx caches build outputs in.nxcache/ to speed up subsequent builds. If you need to clear the cache:
Package-Level Build Commands
Each package has its own build scripts inpackage.json. For example, packages/core/package.json:
Build Tools
The monorepo uses several build tools:- TypeScript - Type checking and
.d.tsgeneration - Rollup - Bundling and transpilation
- Nx - Task orchestration and caching
- npm-run-all (
run-s,run-p) - Running scripts in sequence or parallel - downlevel-dts - Creating TypeScript 3.8-compatible type definitions
Common Build Issues
”Cannot find module” errors
If you see import errors, you may need to rebuild:Stale build artifacts
If you’re seeing unexpected behavior, try cleaning and rebuilding:Circular dependency warnings
Check for circular dependencies in a package:Next Steps
- Run tests after building
- Learn about testing SDK packages locally
- Understand the development workflow