diff --git a/.github/workflows/js_test.yml b/.github/workflows/js_test.yml index b88d4ba18..ba48c5371 100644 --- a/.github/workflows/js_test.yml +++ b/.github/workflows/js_test.yml @@ -44,5 +44,8 @@ jobs: - name: Build i18n libraries run: bundle exec rake react_on_rails:locale + - name: Generate React on Rails packs + run: bundle exec rails react_on_rails:generate_packs + - name: Run js tests run: bundle exec rake ci:js diff --git a/.github/workflows/lint_test.yml b/.github/workflows/lint_test.yml index 48dea7f32..777aaa2b0 100644 --- a/.github/workflows/lint_test.yml +++ b/.github/workflows/lint_test.yml @@ -43,5 +43,8 @@ jobs: - name: Build i18n libraries run: bundle exec rake react_on_rails:locale + - name: Generate React on Rails packs + run: bundle exec rails react_on_rails:generate_packs + - name: Run lint run: bundle exec rake lint diff --git a/.github/workflows/rspec_test.yml b/.github/workflows/rspec_test.yml index ff3a60228..4d5625ec3 100644 --- a/.github/workflows/rspec_test.yml +++ b/.github/workflows/rspec_test.yml @@ -73,6 +73,9 @@ jobs: - name: Build i18n libraries run: bundle exec rake react_on_rails:locale + - name: Generate React on Rails packs + run: bundle exec rails react_on_rails:generate_packs + - name: Build Rescript components run: yarn res:build diff --git a/.gitignore b/.gitignore index 968086ec2..5eb4e1354 100644 --- a/.gitignore +++ b/.gitignore @@ -57,5 +57,7 @@ client/app/bundles/comments/rescript/**/*.bs.js # Using React on Rails default directory /ssr-generated/ -# Generated files -/client/app/generated/ +# Generated React on Rails packs +**/generated/** + +.claude/ diff --git a/Procfile.dev b/Procfile.dev index 90a931b08..20453bbe6 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -2,6 +2,6 @@ # You can run these commands in separate shells rescript: yarn res:dev redis: redis-server -rails: bin/rails s -p 3000 +rails: bundle exec rails s -p 3000 wp-client: HMR=true RAILS_ENV=development NODE_ENV=development bin/shakapacker-dev-server wp-server: bundle exec rake react_on_rails:locale && HMR=true SERVER_BUNDLE_ONLY=yes bin/shakapacker --watch diff --git a/TODO_TURBO_WARNING.md b/TODO_TURBO_WARNING.md new file mode 100644 index 000000000..235609657 --- /dev/null +++ b/TODO_TURBO_WARNING.md @@ -0,0 +1,29 @@ +# TODO: Fix Turbo Warning in Future PR + +## Issue +There's a console warning about Turbo being loaded from within the `
` element instead of the ``. + +## Root Cause +Conflicting requirements between three systems: +1. **Turbo** - Wants to be loaded in `` to avoid re-evaluation on page changes +2. **Shakapacker** - Requires all `append_javascript_pack_tag` calls to happen before the final `javascript_pack_tag` +3. **React on Rails** - The `react_component` helper internally calls `append_javascript_pack_tag` when rendering components in the body + +## Attempted Solutions That Failed +1. Moving `javascript_pack_tag` to head - Breaks because `react_component` calls come after it +2. Using `data-turbo-suppress-warning` - Doesn't properly suppress the warning + +## Potential Future Solutions +1. Extract Turbo into a separate pack from stimulus-bundle and load it in the head +2. Use `prepend_javascript_pack_tag` instead of `append` for component registration +3. Configure React on Rails v16 to use a different component loading strategy +4. Investigate if the auto-registration feature has a different recommended pack loading pattern + +## Current State +The application works correctly with the pack tags at the end of the body. The Turbo warning is cosmetic and doesn't affect functionality. + +## References +- PR #649: Initial v16 migration +- Shakapacker docs: https://github.com/shakacode/shakapacker#view-helper-append_javascript_pack_tag +- Turbo docs: https://turbo.hotwired.dev/handbook/building#working-with-script-elements +- React on Rails v16 docs: https://www.shakacode.com/react-on-rails/docs/ \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 45dbfa272..a79a30a27 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -5,13 +5,9 @@