Skip to content

Post-SWC Migration: Optimization and cleanup tasks #678

@justin808

Description

@justin808

Post-SWC Migration Improvements

After successfully migrating from Babel to SWC in #677, there are several follow-up improvements to consider:

1. Update SWC Dependencies (CRITICAL)

Current versions are significantly outdated:

  • @swc/core: ^1.13.5 (released ~2024)
  • swc-loader: ^0.2.6 (last updated 2022)

Action: Update to latest stable versions for security fixes, performance improvements, and React 19 compatibility.

2. Verify React 19 Compatibility

The project uses React 19.0.0, which was released after SWC 1.13.5. Need to verify:

  • SWC's runtime: 'automatic' transform works correctly with React 19
  • No compatibility issues with React 19 features
  • Consider adding integration tests

3. SWC Development Mode Configuration

babel.config.js has development: !isProductionEnv for better dev error messages. Check if swc.config.js should have equivalent configuration for React transform.

4. Test Coverage and Dual-Transpiler Situation

Current state:

  • Production code: transpiled by SWC
  • Test code: transpiled by Babel (via babel-jest)

Risks:

  • Different transform behaviors between test and production
  • Class name transformations might differ
  • Babel-specific bugs won't be caught

Actions:

  • Add test verifying Stimulus controllers work (class names preserved)
  • Consider migrating Jest to use @swc/jest for consistency
  • Or document why dual transpilers are acceptable

5. Explicit ajv Dependency

Added ajv: ^8.17.1 to resolve module resolution issues. Questions:

  • What specific error occurred without it?
  • Is this a Shakapacker bug that should be reported upstream?
  • Should this be a devDependency?

6. Performance Metrics

Missing actual build time comparisons. Should measure:

# Build times before (Babel) vs after (SWC)
time yarn build:dev
time yarn build:production

Include metrics to validate performance improvements.

7. Babel Dependency Cleanup

Babel is correctly kept for ESLint and Jest, but audit:

  • babel-loader - Still needed if SWC handles webpack?
  • babel-plugin-macros - Are macros still working with SWC?
  • @babel/preset-react - Duplicates SWC's React transform?

Action: Document which Babel packages must be kept and why, then remove unused ones.

Priority

  1. High: Item 1 (Update SWC deps) and Item 2 (React 19 verification)
  2. Medium: Item 4 (Test coverage) and Item 7 (Dependency cleanup)
  3. Low: Item 3, 5, 6 (Nice to have)

Related: #677

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions