Commit 4dee1ff
authored
Add support for RSC (#1644)
* hydrate the component immediately when loaded and registered
* auto register server components and immediately hydrate stores
* move react-server-dom-webpack.d.ts to types directory
* ensure to initialize registered stores array before accessing
* refactor registration callback into separate class
* make the early hydration compatible with turbopack, backward compatible and refactor
* pass rsc path to RSC Client Root and move the config to RORP
* update min node version to 18
* export registerServerComponent as a separate entrypoint to avoid client bundle increase
* Update webpack assets status checker to use server bundle configuration
* Update webpack assets status checker to handle bundle file paths
* [WIP] handle errors happen in rsc payload (#1663)
* stream rsc payload in json objects like streamed react components
* make path to rsc bundle and react client manifest configurable
* feat: Improve client manifest path handling for dev server
- Add `dev_server_url` helper to centralize dev server URL construction
- Add `public_output_uri_path` to get relative webpack output path
- Add `asset_uri_from_packer` to handle asset URIs consistently
- Update `react_client_manifest_file_path` to return dev server URLs when appropriate
- Add comprehensive specs for new asset URI handling
This change ensures client manifest paths are properly resolved to dev server
URLs during development, improving hot-reloading functionality.
* fix: normalize RSC URL path by absorbing leading/trailing slashes
* specify Shakapacker as top-level module
* add tests for RSCClientRoot
* Make RSCClientRoot tests run with react 18
* Update webpack asset path configuration for client manifest
* Fix client startup rendering when the script runs after the page loaded
* Refactor client-side rendering and page lifecycle management
- Extract context and page lifecycle utilities into separate modules
- Improve handling of Turbolinks and Turbo events
- Simplify client startup and rendering process
- Add more robust page load and unload event management
- Rename and reorganize context-related functions
* Add component registry timeout configuration
- Introduce a new configuration option `component_registry_timeout` to control the maximum time to wait for client-side component registration
- Update `CallbackRegistry` to handle timeout events and reject pending callbacks
- Add validation for the timeout configuration in the Rails configuration
- Modify client-side startup and page lifecycle to support the new timeout mechanism
- Enhance error handling for unregistered components and stores
* Refactor CallbackRegistry and clientStartup initialization
- Move `initializeTimeoutEvents()` call to `getOrWaitForItem()` method in CallbackRegistry
- Remove unnecessary 4-second delay in clientStartup
- Clean up commented-out webpack configuration in clientWebpackConfig
* Update StoreRegistry error messages for clarity
* Fix RSC stream parsing to handle incomplete chunks
- Introduce `lastIncompleteChunk` to preserve partial JSON data between stream reads
- Ensure complete JSON chunks are processed by splitting on newlines
- Handle cases where the last chunk is not terminated with a newline
* Refactor CallbackRegistry to improve item tracking and usage
- Introduce `ItemInfo` type to track item registration, usage, and promise details
- Enhance timeout handling with more informative warnings for unused items
- Improve `get`, `has`, and `getAll` methods to better track item usage
- Optimize `getOrWaitForItem` to handle existing promises and registration states
* Refactor CallbackRegistry and ComponentRegistry to simplify item tracking
- Simplify CallbackRegistry by separating item storage and waiting promises
- Introduce separate maps for registered items and waiting promises
- Add a set to track unused items
- Update ComponentRegistry to include a clear method
- Modify test to use new clear method
* Update StoreRegistry test to use clearHydratedStores method
* Update RSC test to append newline to stream chunks
* don't strip the html chunk
* Add "use client" directive to RSCClientRoot
* Convert RSCWebpackLoader to TypeScript
* Comment on the need for workaround
* Fix Knip
* Simplify RSCWebpackLoader
* remove rsc? and stream? render options and add render_mode option
* Rename flight_payload_streaming to rsc_payload_streaming
* Add async component retrieval and timeout handling to ComponentRegistry
* add specs for packs generator
* Update react_on_rails_helper_spec with new props added to component definition script
* Remove webpacker dependency from Gemfile.lock
* Remove unnecessary webpacker mocking in configuration spec
* Update package.json exports for React Server Components
* fix: don't trim html content on server
* Enable prerendering by default for React Server Components
* Rename RSC rendering methods and configuration to payload generation
* add more comments for new components
* linting
* Update package.json exports order for React Server Components
* remove prerender option for stream_react_component
* small linting changes
* Use node 16 to run oldes tests
* Remove unnecessary data-store-dependencies attribute from test scripts
* linting
* Convert loadReactClientManifest to async and update RSC rendering
* make RSCClientRoot tests compatible with React 19
* Test fetch function only with node version 18+
* pass props to RSC generator and avoid state reset on hydration
* Add ignore configuration for Knip static analysis
* small changes
* Implement stream buffering to safely handle stream events and errors
* Fix stream error emission in buffered stream
* Simplify streaming result parsing logic in server rendering
* remove mentions to experiment react 18 and use only react 19
* Refactor registerServerComponent into client and server modules
* Add RSCWebpackPlugin for React Server Components
* Replace react-server-dom-webpack with @shakacode-tools/react-on-rails-rsc
* Update TypeScript configuration and package dependencies for React Server Components
* Remove webpack dependency from package configuration
* Update @shakacode-tools/react-on-rails-rsc dependency to latest commit
* Make reactOnRailsPageLoaded async
* Update configuration to enable force_load by default and modify redux_store helper
* Bump version to 15.0.0-alpha.2 and update CHANGELOG
* revert this: Update package to use @abanoubghadban/react-on-rails-rsc
* Configure .npmrc for private GitHub package registry
* Update import statements for path and fs modules in test file
* Update test specs to add data-force-load attribute by default
* Add null check for ReactOnRails global object in component and store loading scripts
* Bump version to 15.0.0.alpha.2
* Update GitHub Actions workflows to use Shakacode Tools Packages Token
* Update package to use @shakacode-tools/react-on-rails-rsc
* Revert version to 14.2.0 and update CHANGELOG
* Enhance server-side rendering error logging and debugging
- Add full backtrace to error messages for better diagnostics
- Add temporary debugging breakpoint with binding.pry
* Remove temporary debugging breakpoint in server rendering
* Revert gem version to 14.2.0 in Gemfile.lock
* Remove backtrace from server rendering error logging
* Update package to use react-on-rails-rsc package instead of the old private package
* Update CHANGELOG and knip configuration
- Add description for unreleased changes in CHANGELOG
- Remove unused entry from knip configuration
- Add jsdom as a development dependency in knip config
* Change default defer behavior for generated component packs
* Update test to reflect new default defer behavior for generated component packs
* Update CHANGELOG and release notes for React on Rails 15.0.0
- Add comprehensive release notes for version 15.0.0
- Highlight major features: React Server Components support and improved component hydration
- Document breaking changes related to component hydration and store dependencies
- Summarize key improvements in component and store hydration performance
* Add domNodeId support for server-side rendering identifier prefix to support multiple components in the view
* Remove PR references from 15.0.0 release notes1 parent a8b8c03 commit 4dee1ff
File tree
60 files changed
+3173
-628
lines changed- .github/workflows
- docs
- api
- guides
- release-notes
- lib/react_on_rails
- react_component
- server_rendering_pool
- test_helper
- node_package
- src
- registerServerComponent
- types
- tests
- fixtures/rsc-payloads/simple-shell-with-async-component
- script
- spec
- dummy
- spec
- fixtures/automated_packs_generation/components/ReactServerComponents/ror_components
- helpers
- react_on_rails
- test_helper
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
60 files changed
+3173
-628
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
50 | 53 | | |
51 | 54 | | |
52 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
21 | 32 | | |
22 | 33 | | |
23 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
193 | | - | |
194 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
| 28 | + | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
4 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
5 | 17 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
9 | 15 | | |
10 | 16 | | |
11 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
12 | 21 | | |
13 | 22 | | |
14 | 23 | | |
| |||
26 | 35 | | |
27 | 36 | | |
28 | 37 | | |
| 38 | + | |
| 39 | + | |
29 | 40 | | |
30 | 41 | | |
31 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| 22 | + | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| |||
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
42 | | - | |
| 46 | + | |
43 | 47 | | |
44 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
45 | 53 | | |
46 | 54 | | |
47 | 55 | | |
| |||
56 | 64 | | |
57 | 65 | | |
58 | 66 | | |
59 | | - | |
60 | | - | |
| 67 | + | |
| 68 | + | |
61 | 69 | | |
62 | 70 | | |
63 | 71 | | |
| |||
72 | 80 | | |
73 | 81 | | |
74 | 82 | | |
75 | | - | |
| 83 | + | |
| 84 | + | |
76 | 85 | | |
77 | 86 | | |
78 | 87 | | |
| |||
96 | 105 | | |
97 | 106 | | |
98 | 107 | | |
| 108 | + | |
99 | 109 | | |
100 | 110 | | |
101 | 111 | | |
| 112 | + | |
| 113 | + | |
102 | 114 | | |
103 | 115 | | |
104 | 116 | | |
| |||
126 | 138 | | |
127 | 139 | | |
128 | 140 | | |
| 141 | + | |
129 | 142 | | |
130 | 143 | | |
131 | 144 | | |
132 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
133 | 154 | | |
134 | 155 | | |
135 | 156 | | |
| |||
241 | 262 | | |
242 | 263 | | |
243 | 264 | | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
248 | 271 | | |
249 | 272 | | |
250 | 273 | | |
| |||
0 commit comments