Skip to content

Commit ab31233

Browse files
committed
docs: document Turbo warning issue for future investigation
- Add TODO file explaining the root cause of Turbo warning - Document attempted solutions and why they failed - Provide potential future approaches to investigate - This is a cosmetic issue that doesn't affect functionality
1 parent ee5bf38 commit ab31233

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

TODO_TURBO_WARNING.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# TODO: Fix Turbo Warning in Future PR
2+
3+
## Issue
4+
There's a console warning about Turbo being loaded from within the `<body>` element instead of the `<head>`.
5+
6+
## Root Cause
7+
Conflicting requirements between three systems:
8+
1. **Turbo** - Wants to be loaded in `<head>` to avoid re-evaluation on page changes
9+
2. **Shakapacker** - Requires all `append_javascript_pack_tag` calls to happen before the final `javascript_pack_tag`
10+
3. **React on Rails** - The `react_component` helper internally calls `append_javascript_pack_tag` when rendering components in the body
11+
12+
## Attempted Solutions That Failed
13+
1. Moving `javascript_pack_tag` to head - Breaks because `react_component` calls come after it
14+
2. Using `data-turbo-suppress-warning` - Doesn't properly suppress the warning
15+
16+
## Potential Future Solutions
17+
1. Extract Turbo into a separate pack from stimulus-bundle and load it in the head
18+
2. Use `prepend_javascript_pack_tag` instead of `append` for component registration
19+
3. Configure React on Rails v16 to use a different component loading strategy
20+
4. Investigate if the auto-registration feature has a different recommended pack loading pattern
21+
22+
## Current State
23+
The application works correctly with the pack tags at the end of the body. The Turbo warning is cosmetic and doesn't affect functionality.
24+
25+
## References
26+
- PR #649: Initial v16 migration
27+
- Shakapacker docs: https://github.com/shakacode/shakapacker#view-helper-append_javascript_pack_tag
28+
- Turbo docs: https://turbo.hotwired.dev/handbook/building#working-with-script-elements
29+
- React on Rails v16 docs: https://www.shakacode.com/react-on-rails/docs/

0 commit comments

Comments
 (0)