Skip to content

Enhancement: Better auto-registration support for ReScript and transpiled components #2343

@justin808

Description

@justin808

Summary

The auto-registration feature requires manual wrapper components for transpiled languages like ReScript. Components compiled to .bs.js files cannot be directly auto-registered via the ror_components convention.

Current Workaround

Create JavaScript wrapper files in ror_components/:

// bundles/comments/rescript/ReScriptShow/ror_components/RescriptShow.jsx
import RescriptShow from '../ReScriptShow.bs.js';
export default RescriptShow;

Proposal

  1. Extended file extension support: Allow configuration of additional extensions for auto-registration (e.g., .bs.js, .res.js)

  2. Resolution alias: Support aliasing patterns in component discovery:

    config.component_resolution = {
      '.bs.js' => :auto_register,
      '.res.js' => :auto_register
    }
  3. Documentation: Add guidance for ReScript, TypeScript, and other transpiled component integration

Environment

  • React on Rails v16.2.1
  • ReScript v11+ (uses .res.js extension convention)

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