-
-
Notifications
You must be signed in to change notification settings - Fork 638
Open
Labels
Description
Description
Currently, the shakapacker-precompile-hook generator template doesn't include ReScript build support. While the test dummy apps have ReScript integration, users who want to use ReScript with React on Rails need to manually configure their precompile hooks.
Proposed Enhancement
Add optional ReScript support to the React on Rails generator that includes:
- Precompile Hook Enhancement: Add ReScript build step to
bin/shakapacker-precompile-hook - Generator Option: Add
--rescriptflag to the generator (similar to--typescript) - ReScript Configuration: Include proper
rescript.jsonconfiguration - Package.json Scripts: Add
build:rescriptscript when ReScript is enabled - Documentation: Add guide for using ReScript with React on Rails
Implementation Details
The precompile hook should:
- Detect ReScript config files (
rescript.jsonorbsconfig.json) - Validate that
build:rescriptscript exists inpackage.json - Run ReScript build before webpack compilation
- Provide clear error messages if build fails
- Use subshells to avoid directory change side effects
- Handle errors explicitly without relying on
set -e
Current Workaround
Users can manually add ReScript support by modifying their bin/shakapacker-precompile-hook based on the implementation in spec/dummy/bin/shakapacker-precompile-hook.
Related
This enhancement will make React on Rails more accessible to teams using ReScript for type-safe React development.