From 612d9ffb418390e1aa5616dedcd261dc77185187 Mon Sep 17 00:00:00 2001 From: Daniel Choudhury Date: Thu, 26 Oct 2023 22:50:13 +0700 Subject: [PATCH 01/29] Setup handler now setups up apollo ssr --- .../cli/src/commands/experimental/setupStreamingSsrHandler.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/cli/src/commands/experimental/setupStreamingSsrHandler.js b/packages/cli/src/commands/experimental/setupStreamingSsrHandler.js index 007e1bdf7b99..9c431b5a41f7 100644 --- a/packages/cli/src/commands/experimental/setupStreamingSsrHandler.js +++ b/packages/cli/src/commands/experimental/setupStreamingSsrHandler.js @@ -3,6 +3,7 @@ import path from 'path' import { Listr } from 'listr2' +import { addWebPackages } from '@redwoodjs/cli-helpers' import { getConfigPath } from '@redwoodjs/project-config' import { errorTelemetry } from '@redwoodjs/telemetry' @@ -158,6 +159,9 @@ export const handler = async ({ force, verbose }) => { }) }, }, + addWebPackages([ + '@apollo/experimental-nextjs-app-support@0.0.0-commit-b8a73fe', + ]), { task: () => { printTaskEpilogue(command, description, EXPERIMENTAL_TOPIC_ID) From 03fda296166cfd14d6a248b1813dfb91be8bd17a Mon Sep 17 00:00:00 2001 From: Daniel Choudhury Date: Fri, 27 Oct 2023 00:02:42 +0700 Subject: [PATCH 02/29] Add ability to generate delayedPage and setup streaming experiment in test project --- tasks/test-project/codemods/delayedPage.js | 122 +++++++++++++++++++++ tasks/test-project/tasks.js | 78 ++++++++----- tasks/test-project/test-project | 16 ++- tasks/test-project/tui-tasks.js | 28 +---- 4 files changed, 192 insertions(+), 52 deletions(-) create mode 100644 tasks/test-project/codemods/delayedPage.js diff --git a/tasks/test-project/codemods/delayedPage.js b/tasks/test-project/codemods/delayedPage.js new file mode 100644 index 000000000000..1305fd650b4e --- /dev/null +++ b/tasks/test-project/codemods/delayedPage.js @@ -0,0 +1,122 @@ +// @ts-check + +const delayedComponents = ` +function DelayedComponent({ + time, + delays, +}: { + time: number + delays: Map> +}) { + const logged = useRef(false) + if (typeof window === 'undefined') { + const delay = + delays.get(time) ?? + new Promise((resolve) => setTimeout(resolve, time * 1000)) + delays.set(time, delay) + use(delay) + + // eslint-disable-next-line react-hooks/rules-of-hooks + useServerInsertedHTML(() => { + if (!logged.current) { + logged.current = true + return ( +