Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consume RSC response in the server #463

Merged
merged 94 commits into from
Jan 21, 2022
Merged
Changes from 1 commit
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
57bb5f0
wip: Create custom flight renderer with local version of react-server
frandiox Dec 1, 2021
7ed7a73
wip: mock client manifest and add module reference to client components
frandiox Dec 1, 2021
e1eba5f
wip: hack RSC resolution
frandiox Dec 1, 2021
a119de6
wip: wrap component in Proxy to access original properties
frandiox Dec 2, 2021
46c9e06
refactor: rename RSC server files
frandiox Dec 2, 2021
31a1d58
wip: add official RSC hydrator
frandiox Dec 2, 2021
0bada32
fix: Rename response.readRoot and remove explicit hydration
frandiox Dec 3, 2021
a498942
wip: remove RR and Helmet providers from the server
frandiox Dec 3, 2021
4bdac0f
wip: Add test app
frandiox Dec 3, 2021
7406bf2
wip: remove hydration providers
frandiox Dec 3, 2021
81e4548
wip: add renderToReadableStream for RSC
frandiox Dec 3, 2021
2640a8c
refactor: cleanup custom RSC code
frandiox Dec 3, 2021
46dea47
refactor: move and rename files
frandiox Dec 3, 2021
f7f6b51
wip: fix test app
frandiox Dec 3, 2021
2019a6e
refactor: cleanup custom RSC code
frandiox Dec 3, 2021
fc7c30d
refactor: do not pass named boolean in RSC
frandiox Dec 3, 2021
593e6e6
refactor: simplify ClientMarker
frandiox Dec 3, 2021
548b227
test: fix ClientMarker tests
frandiox Dec 3, 2021
b5c1674
fix: delay throwing error when client component is missing
frandiox Dec 3, 2021
6c56da7
refactor: simplify import globs code
frandiox Dec 9, 2021
8c30c09
feat: provide request object to rendering tree
frandiox Dec 21, 2021
2837bef
wip: example of useServerRequest
frandiox Dec 21, 2021
00462a9
feat: inline RSC response in the SSR HTML response
frandiox Dec 21, 2021
ff72d26
fix: add default value to the SSR provider
frandiox Jan 6, 2022
c8e5efb
feat: stream rsc in script tags
frandiox Jan 6, 2022
4a84948
feat: update the starter template to work
blittle Jan 6, 2022
67a11a5
fix: lint errors
blittle Jan 6, 2022
83854c8
refactor: move code around and cleanup
frandiox Jan 7, 2022
2105049
Merge branch 'fd-vite-rsc' into fd-vite-rsc-request-provider
frandiox Jan 7, 2022
c8382dd
chore: upgrade Vite to 2.7.0
frandiox Jan 7, 2022
131a99a
chore: add react-server-dom-vite as vendor
frandiox Jan 7, 2022
6e9cbc7
feat: replace local react-server and react-client with react-server-d…
frandiox Jan 7, 2022
2fa783f
fix: react-server-dom-vite allow exporting hooks from client componen…
frandiox Jan 7, 2022
977d8db
Merge branch 'main' into fd-vite-rsc
blittle Jan 7, 2022
01a534d
fix: move the server logging locations
blittle Jan 7, 2022
cd59155
feat: Implement ReadableStream branch in SSR and RSC
frandiox Jan 7, 2022
67bc790
test: fix playground apps
frandiox Jan 10, 2022
f2fd900
fix: avoid importing undefined exports depending on the running envir…
frandiox Jan 10, 2022
52bdbfe
feat: Buffer RSC response if it cannot be streamed
frandiox Jan 10, 2022
b032e80
fix: tests
blittle Jan 10, 2022
a4d09e5
fix: e2e test
blittle Jan 10, 2022
a4cf4f8
fix: linting
blittle Jan 10, 2022
e106036
Merge branch 'main' into fd-vite-rsc
blittle Jan 10, 2022
c2ac384
fix: rename test helper
blittle Jan 10, 2022
f0b7b3e
fix: update hydrogen template files
blittle Jan 10, 2022
ff0088f
feat: remove react-ssr-prepass. RSC already makes ReadableStream requ…
frandiox Jan 11, 2022
ad17ac8
refactor: simplify hydration calls
frandiox Jan 11, 2022
a60a557
Merge branch 'fd-vite-rsc' of https://github.com/Shopify/hydrogen int…
frandiox Jan 11, 2022
8650188
feat: remove old dependencies
frandiox Jan 11, 2022
7163866
feat: enable tree shaking in worker build
frandiox Jan 11, 2022
bcc4bfc
fix: Release stream lock before piping
frandiox Jan 11, 2022
3bf918c
chore: fix formatting
frandiox Jan 11, 2022
a89af2c
refactor: move code to entry-server to be consistent
frandiox Jan 11, 2022
b32f0f7
refactor: remove HydrationWriter in favor of Node native PassThrough
frandiox Jan 11, 2022
247296e
Merge branch 'fd-vite-rsc' into fd-vite-rsc-request-provider
frandiox Jan 12, 2022
0f25305
fix: move constant to a separate file to avoid importing app logic in…
frandiox Jan 12, 2022
026eb4b
refactor: remove old code
frandiox Jan 12, 2022
990fb66
Merge branch 'fd-vite-rsc' into fd-vite-rsc-request-provider
frandiox Jan 12, 2022
e42b297
fix: maybe fix tests for windows
frandiox Jan 12, 2022
cd1c9b7
Merge branch 'main' into fd-vite-rsc
frandiox Jan 12, 2022
737944b
fix: stream import in workers
frandiox Jan 12, 2022
6bfb3b9
Merge branch 'fd-vite-rsc' into fd-vite-rsc-request-provider
frandiox Jan 12, 2022
b7043ce
fix: flush RSC right after writing head
frandiox Jan 12, 2022
04f20a1
feat: replace RenderCacheProvider with new ServerRequestProvider cache
frandiox Jan 12, 2022
bd04b70
refactor: cleanup
frandiox Jan 12, 2022
6f1e8e7
fix: suspense breaking hydration
frandiox Jan 12, 2022
c56d374
fix: normalize RSC chunks
frandiox Jan 12, 2022
2548619
Merge pull request #390 from Shopify/fd-vite-rsc-request-provider
frandiox Jan 12, 2022
b7fb5fc
refactor: simplify customBody check
frandiox Jan 13, 2022
a185166
feat: minor tree-shaking improvements
frandiox Jan 13, 2022
da7ddb6
fix: enable browser hydration
frandiox Jan 13, 2022
3862b4d
fix: replace TransformStream with ReadableStream to support Firefox
frandiox Jan 13, 2022
0d7e878
refactor: cleanup and rename variables
frandiox Jan 13, 2022
9c373fd
feat: Make ReadableStream globally available
frandiox Jan 13, 2022
3806f8b
wip: consume RSC response in server
frandiox Jan 13, 2022
593d1db
wip: do not close stream connection
frandiox Jan 13, 2022
f7adeb8
chore: Merge branch 'experimental' into fd-vite-rsc-consume-response
jplhomer Jan 19, 2022
2ea3f3a
wip: fix reentrant error with ReadableStreams in RSC
jplhomer Jan 19, 2022
fccfd91
fix: import Node RSC logic dynamically
frandiox Jan 20, 2022
8f52e4a
fix: rename Cache.client.js to avoid bundling it in workers build
frandiox Jan 20, 2022
d5aef68
fix: add temporary monkey patch for React Fizz in workers build
frandiox Jan 20, 2022
d3d64c2
feat: Combine SSR and RSC responses in Node
frandiox Jan 20, 2022
3192734
fix: write RSC before ending response when not streaming
frandiox Jan 20, 2022
e17da24
feat: Combine SSR and RSC responses in Worker
frandiox Jan 20, 2022
f8b0fc7
feat: Use ReadableStream in CFW and stream if supported
frandiox Jan 20, 2022
1474e15
fix: add another temporary monkey patch for React Fizz/Flight in work…
frandiox Jan 20, 2022
d50ffc6
fix: close writable on redirects
frandiox Jan 20, 2022
4c95e02
fix: Fix hydration during dev by using more Suspense boundaries
jplhomer Jan 20, 2022
c3290b2
fix: add back response.socket listener
frandiox Jan 21, 2022
6138b03
feat: support script nonce and shorten access to __flight
frandiox Jan 21, 2022
ec4d678
feat: avoid writing fractional chunks in SSR
frandiox Jan 21, 2022
48836f3
fix: initialize flight container in buffered rendering
frandiox Jan 21, 2022
8bf6c7b
fix: ensure flight container is added in Node
frandiox Jan 21, 2022
c60ed19
refactor: `readable` to `ssrReadable` for clarity
jplhomer Jan 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: import Node RSC logic dynamically
frandiox committed Jan 20, 2022
commit fccfd9110e42bee18a939972a76d8ce4864c70a1
13 changes: 9 additions & 4 deletions packages/hydrogen/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -22,10 +22,8 @@ import {getCacheControlHeader} from './framework/cache';
import {ServerRequestProvider} from './foundation/ServerRequestProvider';
import {setShopifyConfig} from './foundation/useShop';
import type {ServerResponse} from 'http';
import type {PassThrough as PassThroughType} from 'stream';
import type {PassThrough as PassThroughType, Writable} from 'stream';

// @ts-ignore
import {renderToPipeableStream as rscRenderToPipeableStream} from '@shopify/hydrogen/vendor/react-server-dom-vite/writer';
// @ts-ignore
import {renderToReadableStream as rscRenderToReadableStream} from '@shopify/hydrogen/vendor/react-server-dom-vite/writer.browser.server';
// @ts-ignore
@@ -371,7 +369,14 @@ const renderHydrogen: ServerHandler = (App, {shopifyConfig}) => {

return new Response(bufferedBody);
} else {
const stream = rscRenderToPipeableStream(<ReactApp />).pipe(response);
const rscWriter = await import(
// @ts-ignore
'@shopify/hydrogen/vendor/react-server-dom-vite/writer.node.server'
);

const stream = rscWriter
.renderToPipeableStream(<ReactApp />)
.pipe(response) as Writable;

stream.on('finish', function () {
logServerResponse('rsc', log, request, response!.statusCode);