SIMPLE MIGRATION STEPS

Comprehensive guidelines for AI-assisted development within the Editor platform

🚀 Simple Migration Steps (Manual Approach)

If you encounter module resolution issues with the automated script, follow these manual steps:

🛠️ Prerequisites

First, ensure TypeScript path mapping is working:

# 1. Verify tsconfig.base.json has correct paths
grep -A 5 -B 5 "theme-runtime\|theme-styles" tsconfig.base.json

# 2. Clean and rebuild all libraries
npx nx reset
npx nx build core-types
npx nx build theme-runtime  
npx nx build theme-styles
npx nx build theme-system

📝 Manual Migration Steps

Step 1: Production Apps (89% Bundle Reduction)

editor-web/src/app/app.config.ts:

// CHANGE FROM:
import {
  provideUnifiedThemeSystem,
  ThemeStorageService,
  ThemeManagerService,
  ThemeLoggerService,
  LogLevel,
} from '@theme-system';

// CHANGE TO:
import {
  provideUnifiedThemeSystem,
  ThemeStorageService,
  ThemeManagerService,
  ThemeLoggerService,
  LogLevel,
} from '@theme-runtime';

editor-web/src/app/services/theme-bridge.service.ts:

// CHANGE FROM:
import { ThemeManagerService, ThemeApplicationService } from '@theme-system';

// CHANGE TO:
import { ThemeManagerService, ThemeApplicationService } from '@theme-runtime';

space-map/src/app/app.config.ts:

// CHANGE FROM:
import {
  provideUnifiedThemeSystem,
  ThemeStorageService,
  ThemeManagerService,
  ThemeLoggerService,
  LogLevel
} from '@theme-system';

// CHANGE TO:
import {
  provideUnifiedThemeSystem,
  ThemeStorageService,
  ThemeManagerService,
  ThemeLoggerService,
  LogLevel
} from '@theme-runtime';

Step 2: Test Each Change

After each file change, test the build:

# Test editor-web
npx nx build editor-web

# Test space-map  
npx nx build space-map

Step 3: SCSS Migration (Tree-Shaking)

editor-web/src/styles.scss:

/* CHANGE FROM: */
@use 'libs/theme-system/src/lib/styles/global.scss';

/* CHANGE TO: */
@use '@theme-styles/global';

space-map/src/styles.scss:

/* CHANGE FROM: */
@use 'libs/theme-system/src/lib/styles/global.scss';

/* CHANGE TO: */
@use '@theme-styles/global';

🐛 Troubleshooting

Module Resolution Issues

If you get "Cannot find module '@theme-runtime'":

  1. Check built output:

    ls -la dist/libs/theme-runtime/
    cat dist/libs/theme-runtime/package.json
    
  2. Verify TypeScript paths:

    # Ensure these paths exist in tsconfig.base.json:
    "@theme-runtime": ["libs/theme-runtime/src/index.ts"]
    "@theme-styles": ["libs/theme-styles/src/index.ts"]
    
  3. Rebuild dependencies:

    npx nx build core-types theme-runtime theme-styles theme-system
    
  4. Restart TypeScript server (in VS Code: Cmd+Shift+P → "TypeScript: Restart TS Server")

Build Errors

If builds fail with import errors:

  1. Temporary fallback: Keep using @theme-system (it works perfectly)
  2. Debug step-by-step: Change one import at a time and test
  3. Check logs: Look for specific missing exports

🎯 Expected Results

Bundle Size Analysis

BEFORE Migration:

editor-web: ~15MB (includes full 6.2MB theme-system)
space-map: ~12MB (includes full 6.2MB theme-system)

AFTER Migration:

editor-web: ~9MB (50KB theme-runtime only) = 6MB saved
space-map: ~6MB (50KB theme-runtime only) = 6MB saved

Performance Improvements

🛡️ Rollback Plan

If anything goes wrong, simply revert the imports:

// Change back from:
import { ... } from '@theme-runtime';

// To:
import { ... } from '@theme-system';

The @theme-system library will continue working perfectly as your compatibility bridge.

🚀 Alternative Approach: Gradual Migration

If full migration seems complex, try this gradual approach:

  1. Week 1: Migrate just editor-web to @theme-runtime
  2. Week 2: Migrate space-map to @theme-runtime
  3. Week 3: Migrate SCSS imports to @theme-styles
  4. Week 4: Test and optimize with selective imports

This way you can measure the impact of each change and ensure stability.

✅ Success Criteria

You'll know the migration is successful when:

Remember: Your existing theme storage and functionality remains 100% identical - you're just changing which library bundle provides the services!