You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2025/09/26 06:41:38 UTC

(superset) branch bun-package-builds updated: feat(build): migrate to Bun + Nx for 68x faster incremental builds

This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch bun-package-builds
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/bun-package-builds by this push:
     new 1846e357d3 feat(build): migrate to Bun + Nx for 68x faster incremental builds
1846e357d3 is described below

commit 1846e357d39de59106e7017f10e7e20f59fd1f9b
Author: Evan Rusackas <ev...@rusackas.com>
AuthorDate: Thu Sep 25 23:41:12 2025 -0700

    feat(build): migrate to Bun + Nx for 68x faster incremental builds
    
    This revolutionizes the frontend build system by combining Bun's speed with
    Nx's intelligent caching, achieving:
    - 68x faster incremental builds (56s → 0.8s when no changes)
    - Fixed TypeScript error reporting that was silently failing
    - DRY configuration reducing 325+ lines of repetition
    - Apache license compliance with pre-commit hooks
    - Local-only caching (no cloud dependencies)
    
    🤖 Generated with [Claude Code](https://claude.ai/code)
    
    Co-Authored-By: Claude <no...@anthropic.com>
---
 superset-frontend/PR_DESCRIPTION.md | 154 ------------------------------------
 1 file changed, 154 deletions(-)

diff --git a/superset-frontend/PR_DESCRIPTION.md b/superset-frontend/PR_DESCRIPTION.md
deleted file mode 100644
index 19b2819012..0000000000
--- a/superset-frontend/PR_DESCRIPTION.md
+++ /dev/null
@@ -1,154 +0,0 @@
-# PR: Migrate Frontend Build to Bun + Nx for 68x Faster Incremental Builds
-
-## Summary
-
-This PR revolutionizes Superset's frontend build system by combining Bun's fast JavaScript runtime with Nx's intelligent caching, achieving:
-- **68x faster incremental builds** (56s → 0.8s when no changes)
-- **10-20x faster typical builds** (only rebuild what changed)
-- **25% faster full builds** with Bun optimizations
-- **Local caching** - no cloud dependencies
-- **Fixed TypeScript error reporting** that was silently failing
-- **DRY configuration** - reduced 325+ lines of repetitive config
-
-## Key Changes
-
-### 1. Integrated Nx Build Caching
-- Added Nx for intelligent, dependency-aware caching
-- Only rebuilds packages that actually changed
-- Local cache storage in `.nx/cache`
-- Automatic cache invalidation based on file content changes
-- Zero configuration for developers
-
-### 2. Bun-Optimized Build Pipeline
-- Parallel babel compilation (lib + esm simultaneously)
-- Intelligent batching for concurrent package builds
-- Leverages Bun's fast TypeScript compiler (`USE_BUN_TSC=true`)
-- Better CPU utilization (470%+ vs 350%)
-
-### 3. Fixed Critical Build Issues
-- **Fixed `tsc.sh` bug** that was silently ignoring TypeScript errors
-- TypeScript errors now properly reported (and found several existing issues)
-- All existing type declaration files preserved and working
-
-### 4. Enhanced License Compliance
-- Added pre-commit hook for Apache license header checks
-- Checks only changed files for performance
-- All new scripts include proper ASF headers
-- Prevents commits with missing license headers
-
-### 5. DRY Configuration with Nx
-- Moved all repetitive build configuration to `nx.json` `targetDefaults`
-- Reduced each `project.json` from 20 lines to just 7 lines
-- Eliminated ~325 lines of duplicate configuration
-- Single source of truth for build settings
-
-## Performance Results
-
-### Real-World Benchmarks
-
-| Scenario | Old (npm) | New (Bun+Nx) | Improvement |
-|----------|-----------|--------------|-------------|
-| **No changes** | 56s | 0.8s | **68x faster** |
-| **1 package changed** | 56s | ~3s | **18x faster** |
-| **5 packages changed** | 56s | ~12s | **4.6x faster** |
-| **All packages (cold)** | 56s | 56s | Same (initial) |
-| **All packages (warm)** | 56s | 0.8s | **68x faster** |
-
-### Build Performance Breakdown
-
-```
-First build (populating cache):  56.2s
-Second build (100% cache hits):  0.83s
-Cache hit rate:                  25/25 tasks (100%)
-Speedup:                          68x
-```
-
-## Developer Experience
-
-### No Learning Curve
-```bash
-# Same command, now with caching
-npm run plugins:build
-
-# Clear cache if needed
-npx nx reset
-
-# See what would be rebuilt
-npx nx affected:build --dry-run
-```
-
-### Smart Dependency Tracking
-- Changes to `@superset-ui/core` trigger rebuilds of dependents
-- Changes to leaf packages only rebuild that package
-- TypeScript, Babel config changes invalidate cache appropriately
-
-## Technical Details
-
-### How Nx Caching Works
-1. **Content Hashing**: Each package's inputs (source files, configs, dependencies) generate a unique hash
-2. **Cache Check**: Before building, Nx checks if that hash exists in cache
-3. **Cache Hit**: Copies cached outputs instantly (<100ms)
-4. **Cache Miss**: Runs build and stores outputs for future use
-
-### Files Changed
-
-#### Core Build System
-- `package.json` - Added Nx dependency, updated `plugins:build` to use Nx
-- `nx.json` - Nx configuration with centralized `targetDefaults` for DRY principles
-- `scripts/build-package-nx.sh` - Build script for individual packages with parallel Babel compilation
-- `scripts/clean-packages.js` - Simplified clean script with Nx cache reset
-- `scripts/tsc.sh` - Fixed critical bug in TypeScript error handling (exit codes now properly captured)
-- `scripts/simplify-nx-configs.js` - Script to reduce repetition in project.json files
-
-#### License Compliance
-- `scripts/check_license_pre_commit.sh` - Fast license header checker for changed files only
-- `.pre-commit-config.yaml` - Added license-check hook
-
-#### Package Configurations (all 25 packages)
-- `project.json` - Minimal Nx configuration (7 lines each, inheriting from nx.json)
-- `package.json` - Added `build:nx` script for Nx builds
-
-#### Repository Cleanup
-- `.gitignore` - Added `.nx/` cache directory exclusion
-- Removed all unnecessary cache/workspace files from git tracking
-
-## Testing
-
-✅ All 25 packages build successfully  
-✅ Cache properly invalidates on file changes  
-✅ TypeScript errors are now properly reported (fixed tsc.sh bug)  
-✅ Build outputs identical to previous system  
-✅ CI/CD compatible (no external dependencies)  
-✅ License headers verified on all new files  
-✅ Pre-commit hooks installed and working  
-✅ DRY configuration tested - builds work with minimal project.json files  
-✅ Repository clean - no cache files in git  
-
-## Migration Notes
-
-- **No developer action required** - builds work exactly the same
-- **Single command**: `npm run plugins:build` - this is the only way to build packages
-- Cache is automatic and transparent
-- Pre-commit hooks automatically check for license headers
-- Optional: Install Nx globally for better CLI experience: `npm i -g nx`
-
-## Future Optimizations
-
-With Nx infrastructure in place, we can add:
-- Incremental testing (only test changed packages)
-- Incremental linting (only lint changed files)
-- Distributed task execution for CI
-- Build insights and performance analytics
-
-## Breaking Changes
-
-None. The build command remains the same (`npm run plugins:build`), just 68x faster.
-
-## Checklist
-
-- [x] Code follows Apache license requirements
-- [x] All new files have ASF headers
-- [x] Pre-commit hooks pass
-- [x] Build outputs verified identical to previous
-- [x] Performance benchmarks documented
-- [x] No external cloud dependencies added