Skip to content

Improve SWC compiler detection and configuration for Shakapacker 9.3.0+ #1956

@justin808

Description

@justin808

Summary

Improve the SWC compiler detection and default behavior for projects using Shakapacker 9.3.0+.

Background

PR #1896 (now closed) contained valuable SWC improvements that should be extracted and applied to current master.

Proposed Changes

1. Enhance using_swc? Helper

  • Update to properly parse shakapacker.yml for SWC configuration
  • Make SWC the default for Shakapacker 9.3.0+
  • Better fallback logic when config is ambiguous

2. Update Generator

  • Set SWC as default in generated shakapacker.yml for Shakapacker 9.3.0+
  • Add helpful comments in generated config
  • Ensure swc-loader and @swc/core are in devDependencies

3. Documentation

  • Document SWC as the recommended compiler for Shakapacker 9.3.0+
  • Add migration notes for projects upgrading from Babel

Files to Update

From PR #1896 as reference:

  • lib/generators/react_on_rails/base_generator.rb
  • lib/generators/react_on_rails/generator_helper.rb
  • lib/generators/react_on_rails/templates/base/base/config/shakapacker.yml
  • Package.json files (move SWC deps to devDependencies)

Testing

  • Test generator with Shakapacker 9.3.0
  • Test SWC detection logic
  • Verify build works with SWC
  • Test fallback to Babel when SWC not configured

Related

Labels

enhancement

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions