Skip to content

Conversation

rusackas
Copy link
Member

@rusackas rusackas commented Sep 26, 2025

SUMMARY

Note

Bycatch warning: I was annoyed by the lack of license headers, so I added a pre-commit hook to catch that for changed/new files. On CI, that runs on EVERYTHING, and it caught some old files without headers! So you'll see those updates here as well.

This PR updates Superset's frontend build system by combining Bun's fast JavaScript runtime with Nx's intelligent caching, achieving dramatic performance improvements:

  • Faster full builds I forget the benchmarks, but it was about 30% faster or so
  • 68x faster incremental builds (56s → 0.8s when no changes)
  • 10-20x faster typical builds (only rebuild what changed)
  • Fixed TypeScript error reporting that was silently failing
  • DRY configuration - reduced 325+ lines of repetitive config
  • Local caching only - no cloud dependencies

Key Changes

  1. Nx Build Caching: Intelligent, dependency-aware caching that only rebuilds changed packages
  2. Bun-Optimized Pipeline: Parallel Babel compilation with better CPU utilization (470%+ vs 350%)
  3. Fixed tsc.sh Bug: TypeScript errors now properly reported (was silently ignoring errors)
  4. Apache License Compliance: Added pre-commit hooks for license header checking
  5. DRY Configuration: Moved repetitive config to nx.json, reducing each project.json from 20 to 7 lines

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: Every build takes 56s regardless of changes

$ npm run plugins:build
... 56 seconds later ...

After: Incremental builds with caching

$ npm run plugins:build
✔  25/25 tasks [25 read from cache]
... 0.8 seconds ...

Performance 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

TESTING INSTRUCTIONS

  1. Test the build system:

    # Clean install and initial build
    npm ci
    npm run plugins:build  # First build: ~56s (populating cache)
    
    # Test cache hit
    npm run plugins:build  # Second build: ~0.8s (100% cache hits)
    
    # Test incremental build
    echo "// test" >> superset-frontend/plugins/plugin-chart-table/src/index.ts
    npm run plugins:build  # Only rebuilds plugin-chart-table and dependents
  2. Verify TypeScript error reporting:

    # Add a type error to any package
    echo "const x: string = 123;" >> superset-frontend/packages/superset-ui-core/src/index.ts
    npm run plugins:build  # Should fail with TypeScript error
    git restore superset-frontend/packages/superset-ui-core/src/index.ts
  3. Test license compliance:

    # Create a file without license header
    echo "console.log('test');" > test.js
    git add test.js
    git commit -m "test"  # Pre-commit hook should fail
    rm test.js

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API (Nx build caching)
  • Removes existing feature or API

Notes:

  • No breaking changes - npm run plugins:build works exactly the same, just faster
  • All build outputs are identical to the previous system
  • Pre-commit hooks automatically installed on npm install
  • Local caching only (no Nx Cloud), stored in .nx/cache

rusackas and others added 4 commits September 25, 2025 21:57
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 <[email protected]>
Copy link

korbit-ai bot commented Sep 26, 2025

Based on your review schedule, I'll hold off on reviewing this PR until it's marked as ready for review. If you'd like me to take a look now, comment /korbit-review.

Your admin can change your review schedule in the Korbit Console

@rusackas rusackas changed the title feat(build): migrate to Bun + Nx for 68x faster incremental builds feat(build): POC — migrate to Bun + Nx for 68x faster incremental builds Sep 26, 2025
The new pre-commit hook caught several files that were missing
Apache license headers. This commit adds the required headers to:

- Devcontainer scripts (.sh files)
- Python __init__.py files
- Storybook configuration files (.js)
- Vendor JavaScript files (with preserved vendor notices)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@rusackas rusackas changed the title feat(build): POC — migrate to Bun + Nx for 68x faster incremental builds feat(packages): POC — migrate to Bun + Nx for 68x faster incremental package/plugin builds Sep 26, 2025
@rusackas rusackas changed the title feat(packages): POC — migrate to Bun + Nx for 68x faster incremental package/plugin builds feat(packages): POC — migrate to Bun + Nx for faster incremental package/plugin builds Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant