|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Development Commands |
| 6 | + |
| 7 | +### Essential Commands |
| 8 | +- **Install dependencies**: `bundle && yarn` |
| 9 | +- **Run tests**: |
| 10 | + - Ruby tests: `rake run_rspec` |
| 11 | + - JavaScript tests: `yarn run test` or `rake js_tests` |
| 12 | + - All tests: `rake` (default task runs lint and all tests except examples) |
| 13 | +- **Linting**: |
| 14 | + - All linters: `rake lint` (runs ESLint and RuboCop) |
| 15 | + - ESLint only: `yarn run lint` or `rake lint:eslint` |
| 16 | + - RuboCop only: `rake lint:rubocop` |
| 17 | +- **Build**: `yarn run build` (compiles TypeScript to JavaScript in node_package/lib) |
| 18 | +- **Type checking**: `yarn run type-check` |
| 19 | + |
| 20 | +### Development Setup Commands |
| 21 | +- **Initial setup**: `bundle && yarn && rake shakapacker_examples:gen_all && rake node_package && rake` |
| 22 | +- **Prepare examples**: `rake shakapacker_examples:gen_all` |
| 23 | +- **Generate node package**: `rake node_package` |
| 24 | +- **Run single test example**: `rake run_rspec:example_basic` |
| 25 | + |
| 26 | +### Test Environment Commands |
| 27 | +- **Dummy app tests**: `rake run_rspec:dummy` |
| 28 | +- **Gem-only tests**: `rake run_rspec:gem` |
| 29 | +- **All tests except examples**: `rake all_but_examples` |
| 30 | + |
| 31 | +## Project Architecture |
| 32 | + |
| 33 | +### Dual Package Structure |
| 34 | +This project maintains both a Ruby gem and an NPM package: |
| 35 | +- **Ruby gem**: Located in `lib/`, provides Rails integration and server-side rendering |
| 36 | +- **NPM package**: Located in `node_package/src/`, provides client-side React integration |
| 37 | + |
| 38 | +### Core Components |
| 39 | + |
| 40 | +#### Ruby Side (`lib/react_on_rails/`) |
| 41 | +- **`helper.rb`**: Rails view helpers for rendering React components |
| 42 | +- **`server_rendering_pool.rb`**: Manages Node.js processes for server-side rendering |
| 43 | +- **`configuration.rb`**: Global configuration management |
| 44 | +- **`engine.rb`**: Rails engine integration |
| 45 | +- **Generators**: Located in `lib/generators/react_on_rails/` |
| 46 | + |
| 47 | +#### JavaScript/TypeScript Side (`node_package/src/`) |
| 48 | +- **`ReactOnRails.ts`**: Main entry point for client-side functionality |
| 49 | +- **`serverRenderReactComponent.ts`**: Server-side rendering logic |
| 50 | +- **`ComponentRegistry.ts`**: Manages React component registration |
| 51 | +- **`StoreRegistry.ts`**: Manages Redux store registration |
| 52 | + |
| 53 | +### Build System |
| 54 | +- **Ruby**: Standard gemspec-based build |
| 55 | +- **JavaScript**: TypeScript compilation to `node_package/lib/` |
| 56 | +- **Testing**: Jest for JS, RSpec for Ruby |
| 57 | +- **Linting**: ESLint for JS/TS, RuboCop for Ruby |
| 58 | + |
| 59 | +### Examples and Testing |
| 60 | +- **Dummy app**: `spec/dummy/` - Rails app for testing integration |
| 61 | +- **Examples**: Generated via rake tasks for different webpack configurations |
| 62 | +- **Rake tasks**: Defined in `rakelib/` for various development operations |
| 63 | + |
| 64 | +## Important Notes |
| 65 | +- Use `yalc` for local development when testing with external apps |
| 66 | +- The project supports both Webpacker and Shakapacker |
| 67 | +- Server-side rendering uses isolated Node.js processes |
| 68 | +- React Server Components support available in Pro version |
| 69 | +- Generated examples are in `gen-examples/` (ignored by git) |
| 70 | + |
| 71 | +## IDE Configuration |
| 72 | +Exclude these directories to prevent IDE slowdowns: |
| 73 | +- `/coverage`, `/tmp`, `/gen-examples`, `/node_package/lib` |
| 74 | +- `/node_modules`, `/spec/dummy/node_modules`, `/spec/dummy/tmp` |
| 75 | +- `/spec/dummy/app/assets/webpack`, `/spec/dummy/log` |
0 commit comments