PACKAGE JSON SCRIPTS GUIDE

Documentation for Developers

๐Ÿ“‹ Package.json Scripts Guide - Safe Build Commands

Date: October 20, 2025
Purpose: Complete guide to rebuild apps and libraries safely
Status: โœ… VERIFIED SAFE


๐ŸŽฏ Quick Answer: Which Commands Should I Use?

For Libraries (Most Common):

yarn build:libs          # โ† RECOMMENDED: Rebuild all NX libraries

For Apps:

yarn build:gograb        # โ† Rebuild gograb-space app
yarn build:space-admin   # โ† Rebuild space-admin app
yarn build:atlas-admin   # โ† Rebuild atlas-admin app

For Everything:

yarn build:all           # โ† Rebuild libs + apps (full build)

๐Ÿ“Š Complete Script Analysis

๐Ÿš€ NEW AUTOMATION SYSTEM (Lines 13-23) - RECOMMENDED

build:all โœ… SAFE - RECOMMENDED

yarn build:all

build:libs:auto โœ… SAFE - RECOMMENDED

yarn build:libs:auto

build:apps:auto โœ… SAFE

yarn build:apps:auto

๐Ÿ—๏ธ BUILD COMMANDS (Lines 97-101) - CUSTOM BUILDER

build:libs โœ… SAFE - MOST RECOMMENDED FOR LIBS

yarn build:libs

โš ๏ธ IMPORTANT: This uses the custom builder we just fixed!

build:apps โœ… SAFE

yarn build:apps

build โœ… SAFE

yarn build

๐ŸŒŒ GOGRAB SPACE ECOSYSTEM (Lines 30-43)

build:gograb โœ… SAFE

yarn build:gograb

build:gograb:fast โš ๏ธ SAFE BUT SKIPS CACHE

yarn build:gograb:fast

build:space-admin โœ… SAFE

yarn build:space-admin

build:atlas-admin โœ… SAFE

yarn build:atlas-admin

build:ecosystem โœ… SAFE - BUILDS MULTIPLE APPS

yarn build:ecosystem

build:libs:features โœ… SAFE - SPECIFIC LIBS

yarn build:libs:features

โš ๏ธ RISKY COMMANDS - USE WITH CAUTION

build:safe โš ๏ธ BYPASSES CACHE

yarn build:safe

build:quick โš ๏ธ SKIPS CACHE + NO CLEAN

yarn build:quick

perf:cleanup โš ๏ธ NUCLEAR OPTION

yarn perf:cleanup

๐ŸŽฏ Recommended Workflows

Workflow 1: After Enabling Declaration Maps

# Step 1: Clean previous builds
yarn nx reset

# Step 2: Rebuild all libraries (CRITICAL for declaration maps)
yarn build:libs

# Step 3: Verify maps were generated
find dist/libs -name "*.d.ts.map" | wc -l
# Should show > 0

# Step 4: Restart TypeScript server
# Cmd+Shift+P โ†’ "TypeScript: Restart TS Server"

# Step 5: Test "Go to Definition"
# Option+Click on any type โ†’ Should open source file!

Workflow 2: Daily Development

# Rebuild specific library you're working on
yarn nx build <library-name>

# Or rebuild all feature libraries
yarn build:libs:features

# Or rebuild everything
yarn build:libs

Workflow 3: Before Committing

# Full build to catch any issues
yarn build:all

# Run tests
yarn test:ecosystem

# Check health
yarn health:full

Workflow 4: If Things Are Broken

# Step 1: Health check
yarn health:full

# Step 2: Simple fix
yarn crash:fix

# Step 3: If still broken, nuclear option
yarn crash:nuclear

# Step 4: Clean rebuild
yarn nx reset
yarn install
yarn build:all

๐Ÿ“Š Script Comparison

Script Speed Cache Declaration Maps Use Case
build:libs โšกโšกโšก Fast โœ… Yes โœ… Yes (NEW!) RECOMMENDED for libs
build:libs:auto โšกโšก Medium โœ… Yes โš ๏ธ Unknown Alternative automation
build:all โšก Slow โœ… Yes โœ… Yes Full rebuilds
build:gograb โšกโšกโšก Fast โœ… Yes N/A (app) Specific app
build:ecosystem โšกโšก Medium โœ… Yes N/A (apps) All ecosystem apps
build:libs:features โšกโšกโšก Fast โœ… Yes โš ๏ธ Maybe Specific libs only
build:safe โšก Slow โŒ No โœ… Yes Cache issues
build:quick โšกโšก Medium โŒ No โœ… Yes Quick iteration

๐ŸŽ“ Understanding the Difference

build:libs vs build:libs:auto

build:libs:

"build:libs": "NODE_OPTIONS=\"--max-old-space-size=8192\" node tools/build-scripts/build-libs.js"

build:libs:auto:

"build:libs:auto": "node build.js --libs-only"

Recommendation: Use build:libs for consistency with our fix!


๐Ÿšจ What NOT To Do

โŒ DON'T: Mix Build Systems

# Bad - inconsistent builds
yarn build:libs          # Custom builder
yarn build:libs:auto     # Automation system
yarn nx build some-lib   # NX native

Instead: Pick one system and stick with it!

โŒ DON'T: Skip Cache Without Reason

# Bad - unnecessarily slow
yarn build:gograb:fast --skip-nx-cache

Instead: Only skip cache if you have cache corruption!

โŒ DON'T: Run Multiple Builds Simultaneously

# Bad - resource exhaustion!
yarn build:libs &
yarn build:apps &
yarn build:ecosystem &

Instead: Run builds sequentially or use build:all!


โœ… Safe Build Checklist

Before running any build command:


๐ŸŽฏ Final Recommendations

For Your Current Task (Go to Definition Fix):

# The ONLY command you need:
yarn build:libs

# This will:
# โœ… Use the custom builder we just fixed
# โœ… Respect declarationMap: true in tsconfig
# โœ… Generate all .d.ts.map files
# โœ… Clean up source pollution
# โœ… Build all 42+ libraries properly

For Daily Development:

1. Rebuilding libraries:

yarn build:libs         # โ† RECOMMENDED

2. Rebuilding specific app:

yarn build:gograb       # โ† SAFE AND FAST

3. Rebuilding everything:

yarn build:all          # โ† COMPREHENSIVE

For Troubleshooting:

1. First, try health check:

yarn health:full

2. If issues found, try simple fix:

yarn crash:fix

3. If still broken, nuclear option:

yarn crash:nuclear
yarn install
yarn build:all

๐Ÿ“š Related Documentation


Last Updated: October 20, 2025
Status: โœ… VERIFIED - ALL COMMANDS ANALYZED
Recommended for Libraries: yarn build:libs
Recommended for Apps: yarn build:gograb (or specific app)
Recommended for Everything: yarn build:all

Key Insight: After our fix to build-angular-library.js, yarn build:libs will now properly generate declaration maps! ๐ŸŽ‰