Commit c3f432b
authored
Use RSC payload to render server components on server (#1696)
* add needed utils to use rsc payload on the server
* Refactor component registration and rendering logic to support `server-component-reference` type
* Revert "Refactor component registration and rendering logic to support `server-component-reference` type"
This reverts commit 8df9e11.
* Enhance ReactOnRails options management
* Revert "Enhance ReactOnRails options management"
This reverts commit 2f99ea9.
* add support for returning promise of react component from render function
* Update ReactOnRails configuration to rename server manifest file for consistency. Adjust related methods and references to use the new naming convention for the server client manifest file.
* Refactor ReactOnRails to support React Server Components (RSC) registration and rendering
* embed rsc payload inside the html page
* linting
* fix ts errors
* tmp
* linting
* linting
* Update RSCClientRoot and related files to use RSCPayloadChunk type for improved type safety in RSC streaming and handling.
* Reset render state after processing each chunk to prevent error carryover in stream rendering.
* Update RailsContext type to make rscPayloadGenerationUrl optional
* Fix formatting in ReactOnRails helper for consistency
* Update error handling in createPromiseResult to return errorRenderState instead of renderState
* Refactor RSCServerRoot to use RailsContext in generateRSCPayload and improve error messaging for missing manifest files
* Add .yalc directory to ESLint ignore patterns
* update changelog
* rename __FLIGHT_DATA to REACT_ON_RAILS_RSC_PAYLOAD for improved clarity and consistency in RSC streaming handling.
* Enhance type safety in RSCClientRoot and RSCPayloadContainer by using RSCPayloadChunk type, and improve documentation for chunk handling and transfer resilience.
* convert createElement calls to jsx
* rename transformRSCNodeStreamAndReplayConsoleLogs to transformRSCNodeStream
* Enhance RSCPayloadContainer documentation on escape sequences and modify chunk index validation in RSCServerRoot for improved error handling.
* refactoring
* remove unnecessary keys and streamline component rendering, enhancing code clarity and maintainability.
* Update import paths in server.rsc.ts to include file extensions for improved clarity and consistency.
* Update import statement in server.ts to use .tsx extension for RSCServerRoot
* Add ability to render server components inside client components (add support for react-router) (#1736)
* replace RSCPayloadContainer with RSC injection utils
* Add renderRequestId to rendering options and context for improved request tracking
- Introduced renderRequestId in render options to uniquely identify each render request.
- Updated server rendering code to include renderRequestId in the context.
- Enhanced client-side rendering to handle and log renderRequestId.
- Modified type definitions to accommodate the new renderRequestId field in RailsContext.
- Improved debugging output in RailsContext component for better visibility of context data.
* tmp
* trace used rsc payload streams on server and pass them to client
* replace registerRouter with wrapServerComponentRenderer utility function
* add artifical delay amd log statements
* Revert "add artifical delay amd log statements"
This reverts commit cd57337.
* Update import statements to include file extensions
* add missing docs and specs
* remove RSCRoots and replace its test with registerServerComponent tests
* update injectRSCPayload tests to expect the new behavior
* fix streamServerRenderedReactComponent and helper specs
* Update renderContextRows to exclude 'componentSpecificMetadata' from rendering
* fix knip errors
* Remove RSCServerRoot entry from package.json
* add test to test the behavior of hydrating Suspensable components
* initialize the rsc payload array in a sync manner when the generate rsc function is called to avoid hydration race conditions
* fix failing jest tests
* add TypeScript ignore comment in SuspenseHydration test for Node 18+ compatibility
* remove options parameter from registerServerComponent and update related tests
* refactor: rename WrapServerComponentRenderer to wrapServerComponentRenderer
* docs: add detailed JSDoc comments for RSC functions and utilities to improve code clarity and maintainability
* feat: implement post-SSR hooks for enhanced server-side rendering control and update package dependencies
* refactor: improve type safety in server component loading and streamline import statements
* fix: update module loading configuration to use environment-specific prefix and set crossOrigin to null
* refactor: update react-on-rails-rsc dependency to use SSR support and streamline imports for server components
* chore: update acorn and acorn-loose dependencies in yarn.lock to latest versions for improved compatibility
* refactor: clarify test description for child async component hydration in SuspenseHydration test
* fix problem of returning the wrong stream
* refactor: update RailsContext types to include server component capabilities and streamline related functions
* refactor: rename rscPayloadGenerationUrl to rscPayloadGenerationUrlPath and enhance type safety in RailsContext
* refactor: enhance error handling and improve code clarity in server component rendering and tests
* handle trailing commas while removing packages from at CI "oldest" tests
* don't run SuspenseHydration tests with CI oldest tests
* chore: update testPathIgnorePatterns to exclude additional test cases in CI
* chore: escape quotes in testPathIgnorePatterns for proper parsing in CI
* refactor: update RailsContext usage in tests to utilize RailsContextWithServerComponentCapabilities for improved type safety
* refactor: update test cases to use rscPayloadGenerationUrlPath for consistency in RailsContext
* refactor: unify stream types by introducing PipeableOrReadableStream
* refactor: replace direct checks for RSC support with a utility method for improved clarity and maintainability
* refactor: update stubbing in packs_generator_spec to improve clarity and maintainability
* refactor: make renderRequestId optional in server component rendering for improved flexibility and clarity
* refactor: remove renderRequestId from script tags in ReactOnRailsHelper specs for improved clarity
* refactor: optimize RSC payload handling and improve hook management for better performance and clarity
* refactor: ensure RSC support variable is reset in packs_generator_spec for improved test isolation
* refactor: enhance RSC component handling by introducing promise wrapper and improving stream processing for better error management
* refactor: make serverSideRSCPayloadParameters optional in RailsContextWithServerComponentCapabilities for improved flexibility
* handle error happen during rsc payload generation
* add rsc payload url to context only if rsc support enabled
* removed unneeded rubocop disable statement
* Enhance error handling and memory management in RSC payload processing
* add a bility to refetch and retry fetching of server components
* Update import statements in client and server components to use .tsx extension for RSCRoute
* removed the functionality of caching components, react already caches them
* delete unused file and update knip configs
* Refactor RSC handling to improve performance and error management
* Fix test expectations for fetch calls in registerServerComponent tests to use URL-encoded props format.
* Enhance error handling in server component rendering and RSC payload processing by adding catch blocks for promise rejections and error events in streams.
* Update react-on-rails-rsc dependency to version 19.0.1 in package.json and yarn.lock
* update react to v19.1.0
* Revert "update react to v19.1.0"
This reverts commit 9206e01.
* Update react-on-rails-rsc dependency to version 19.0.2 in package.json and yarn.lock
* ensure to send the rsc payload array initilization before the html chunk
* Update changelog.md1 parent 57938d0 commit c3f432b
File tree
54 files changed
+2433
-480
lines changed- docs/guides
- lib/react_on_rails
- react_component
- test_helper
- node_package
- src
- registerServerComponent
- types
- wrapServerComponentRenderer
- tests
- script
- spec
- dummy
- client/app/components
- spec
- react_on_rails
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
54 files changed
+2433
-480
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
26 | 34 | | |
27 | 35 | | |
28 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
107 | 132 | | |
108 | 133 | | |
109 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
74 | | - | |
| 75 | + | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| |||
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
| 100 | + | |
99 | 101 | | |
100 | 102 | | |
101 | 103 | | |
| |||
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
131 | 139 | | |
132 | 140 | | |
133 | 141 | | |
| |||
153 | 161 | | |
154 | 162 | | |
155 | 163 | | |
156 | | - | |
| 164 | + | |
157 | 165 | | |
158 | 166 | | |
159 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
13 | 17 | | |
14 | 18 | | |
15 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
69 | | - | |
| 71 | + | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| |||
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
85 | | - | |
| 87 | + | |
| 88 | + | |
86 | 89 | | |
87 | 90 | | |
88 | 91 | | |
| |||
112 | 115 | | |
113 | 116 | | |
114 | 117 | | |
| 118 | + | |
115 | 119 | | |
116 | 120 | | |
117 | 121 | | |
| |||
305 | 309 | | |
306 | 310 | | |
307 | 311 | | |
308 | | - | |
| 312 | + | |
| 313 | + | |
309 | 314 | | |
310 | 315 | | |
311 | 316 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
| 376 | + | |
376 | 377 | | |
377 | 378 | | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
378 | 384 | | |
379 | 385 | | |
380 | 386 | | |
| |||
644 | 650 | | |
645 | 651 | | |
646 | 652 | | |
647 | | - | |
| 653 | + | |
| 654 | + | |
648 | 655 | | |
649 | 656 | | |
650 | 657 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
93 | | - | |
| 92 | + | |
94 | 93 | | |
95 | 94 | | |
96 | | - | |
97 | | - | |
98 | 95 | | |
99 | 96 | | |
100 | 97 | | |
101 | | - | |
102 | | - | |
103 | | - | |
| 98 | + | |
104 | 99 | | |
105 | 100 | | |
106 | 101 | | |
| |||
146 | 141 | | |
147 | 142 | | |
148 | 143 | | |
149 | | - | |
150 | | - | |
| 144 | + | |
151 | 145 | | |
152 | 146 | | |
153 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
18 | 26 | | |
19 | 27 | | |
20 | | - | |
| 28 | + | |
21 | 29 | | |
22 | 30 | | |
23 | 31 | | |
| |||
139 | 147 | | |
140 | 148 | | |
141 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
142 | 154 | | |
143 | 155 | | |
144 | 156 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
| |||
0 commit comments