Commit 6b2f6a2
authored
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 statement1 parent e43fd8d commit 6b2f6a2
File tree
49 files changed
+2088
-771
lines changed- docs/guides
- lib/react_on_rails
- react_component
- 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.
49 files changed
+2088
-771
lines changed| 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 | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
165 | 165 | | |
166 | 166 | | |
167 | 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 | | - | |
| 10 | + | |
| 11 | + | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
315 | | - | |
316 | | - | |
317 | 315 | | |
318 | 316 | | |
319 | 317 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
361 | | - | |
| 361 | + | |
362 | 362 | | |
363 | 363 | | |
364 | 364 | | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | 365 | | |
370 | 366 | | |
371 | 367 | | |
| |||
381 | 377 | | |
382 | 378 | | |
383 | 379 | | |
384 | | - | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
385 | 384 | | |
386 | 385 | | |
387 | 386 | | |
| |||
439 | 438 | | |
440 | 439 | | |
441 | 440 | | |
442 | | - | |
| 441 | + | |
443 | 442 | | |
444 | 443 | | |
445 | 444 | | |
| |||
651 | 650 | | |
652 | 651 | | |
653 | 652 | | |
654 | | - | |
| 653 | + | |
| 654 | + | |
655 | 655 | | |
656 | 656 | | |
657 | 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 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
131 | 136 | | |
132 | 137 | | |
133 | 138 | | |
| |||
208 | 213 | | |
209 | 214 | | |
210 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
211 | 225 | | |
212 | 226 | | |
213 | 227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
86 | 98 | | |
87 | 99 | | |
88 | 100 | | |
| |||
93 | 105 | | |
94 | 106 | | |
95 | 107 | | |
96 | | - | |
| 108 | + | |
97 | 109 | | |
98 | 110 | | |
99 | 111 | | |
| |||
108 | 120 | | |
109 | 121 | | |
110 | 122 | | |
111 | | - | |
| 123 | + | |
112 | 124 | | |
113 | 125 | | |
114 | 126 | | |
| |||
0 commit comments