From 5094cb5025964c22d15024cc06999f7c00e8f7eb Mon Sep 17 00:00:00 2001 From: Cody Olsen <81981+stipsan@users.noreply.github.com> Date: Wed, 29 Nov 2023 20:29:21 +0100 Subject: [PATCH] feat!: enable turbo mode for everyone (#705) --- apps/next-app-router/app/Variant.tsx | 9 +- apps/next-app-router/app/layout.tsx | 2 + apps/next-app-router/app/page.tsx | 4 + .../app/variants/default/index.tsx | 3 - .../variants/groq-store/PreviewProvider.tsx | 7 +- apps/next-app-router/next.config.mjs | 3 +- apps/next-pages-router/next.config.mjs | 3 +- apps/next-pages-router/src/pages/index.tsx | 25 +-- apps/remix/app/routes/index.tsx | 2 + apps/remix/app/variants/live-store/index.tsx | 10 +- packages/preview-kit/.gitignore | 4 - packages/preview-kit/README.md | 55 ----- packages/preview-kit/package.config.ts | 55 +++-- packages/preview-kit/package.json | 53 ++--- .../react-server/live-query/index.client.js | 3 - .../react-server/live-query/index.js | 8 - .../GroqStoreProvider/GroqStoreProvider.tsx | 200 ------------------ .../src/GroqStoreProvider/index.ts | 2 - .../LiveQuery/LiveQueryClientComponent.tsx | 70 ------ .../LiveQuery/createConditionalLiveQuery.tsx | 97 --------- packages/preview-kit/src/LiveQuery/index.tsx | 16 -- .../LiveQueryProvider.tsx} | 122 +++++------ .../createLiveQueryProvider.tsx | 159 -------------- .../src/LiveQueryProvider/index.ts | 20 ++ .../src/LiveQueryProvider/index.tsx | 14 -- .../src/LiveStoreProvider/index.ts | 2 - packages/preview-kit/src/_exports/client.ts | 1 - packages/preview-kit/src/_exports/index.ts | 10 - .../_create-conditional-live-query.ts | 1 - .../src/_exports/internals/_live-query.ts | 2 - .../src/_exports/live-query.test.ts | 10 - .../preview-kit/src/_exports/live-query.ts | 2 - .../preview-kit/src/client/createClient.ts | 1 + packages/preview-kit/src/client/types.ts | 1 + packages/preview-kit/src/context.ts | 18 +- packages/preview-kit/src/hooks.ts | 74 +++---- packages/preview-kit/src/index.ts | 16 ++ .../preview-kit/src/live-query/LiveQuery.tsx | 84 ++++++++ .../live-query/LiveQueryClientComponent.tsx | 74 +++++++ packages/preview-kit/src/live-query/index.ts | 10 + .../{LiveQuery => live-query}/useLiveQuery.ts | 33 +-- packages/preview-kit/src/no-store.ts | 50 ----- packages/preview-kit/src/types.ts | 23 +- packages/preview-kit/src/utils.ts | 68 ------ packages/preview-kit/src/utils/useParams.ts | 16 ++ packages/preview-kit/tsconfig.build.json | 2 +- packages/preview-kit/tsconfig.json | 2 +- packages/preview-kit/turbo.json | 9 +- pnpm-lock.yaml | 105 +++++---- 49 files changed, 506 insertions(+), 1054 deletions(-) delete mode 100644 apps/next-app-router/app/variants/default/index.tsx delete mode 100644 packages/preview-kit/.gitignore delete mode 100644 packages/preview-kit/react-server/live-query/index.client.js delete mode 100644 packages/preview-kit/react-server/live-query/index.js delete mode 100644 packages/preview-kit/src/GroqStoreProvider/GroqStoreProvider.tsx delete mode 100644 packages/preview-kit/src/GroqStoreProvider/index.ts delete mode 100644 packages/preview-kit/src/LiveQuery/LiveQueryClientComponent.tsx delete mode 100644 packages/preview-kit/src/LiveQuery/createConditionalLiveQuery.tsx delete mode 100644 packages/preview-kit/src/LiveQuery/index.tsx rename packages/preview-kit/src/{LiveStoreProvider/LiveStoreProvider.tsx => LiveQueryProvider/LiveQueryProvider.tsx} (88%) delete mode 100644 packages/preview-kit/src/LiveQueryProvider/createLiveQueryProvider.tsx create mode 100644 packages/preview-kit/src/LiveQueryProvider/index.ts delete mode 100644 packages/preview-kit/src/LiveQueryProvider/index.tsx delete mode 100644 packages/preview-kit/src/LiveStoreProvider/index.ts delete mode 100644 packages/preview-kit/src/_exports/client.ts delete mode 100644 packages/preview-kit/src/_exports/index.ts delete mode 100644 packages/preview-kit/src/_exports/internals/_create-conditional-live-query.ts delete mode 100644 packages/preview-kit/src/_exports/internals/_live-query.ts delete mode 100644 packages/preview-kit/src/_exports/live-query.test.ts delete mode 100644 packages/preview-kit/src/_exports/live-query.ts create mode 100644 packages/preview-kit/src/index.ts create mode 100644 packages/preview-kit/src/live-query/LiveQuery.tsx create mode 100644 packages/preview-kit/src/live-query/LiveQueryClientComponent.tsx create mode 100644 packages/preview-kit/src/live-query/index.ts rename packages/preview-kit/src/{LiveQuery => live-query}/useLiveQuery.ts (74%) delete mode 100644 packages/preview-kit/src/no-store.ts delete mode 100644 packages/preview-kit/src/utils.ts create mode 100644 packages/preview-kit/src/utils/useParams.ts diff --git a/apps/next-app-router/app/Variant.tsx b/apps/next-app-router/app/Variant.tsx index 2637fad1..847d39c8 100644 --- a/apps/next-app-router/app/Variant.tsx +++ b/apps/next-app-router/app/Variant.tsx @@ -1,13 +1,12 @@ -import dynamic from 'next/dynamic' +import { lazy } from 'react' -const DefaultVariant = dynamic(() => import('./variants/default')) -const GroqStoreVariant = dynamic(() => import('./variants/groq-store')) -const LiveStoreVariant = dynamic(() => import('./variants/live-store')) +const GroqStoreVariant = lazy(() => import('./variants/groq-store')) +const LiveStoreVariant = lazy(() => import('./variants/live-store')) export default function Variant(props: React.PropsWithChildren) { switch (process.env.VARIANT || 'default') { case 'default': - return + return <>{props.children} case 'groq-store': return case 'live-store': diff --git a/apps/next-app-router/app/layout.tsx b/apps/next-app-router/app/layout.tsx index f46d8e6d..5aa61589 100644 --- a/apps/next-app-router/app/layout.tsx +++ b/apps/next-app-router/app/layout.tsx @@ -4,6 +4,8 @@ import { unstable__adapter, unstable__environment } from '@sanity/client' import DraftModeButton from './DraftModeButton' import type { Metadata } from 'next' +export const runtime = 'edge' + export const metadata: Metadata = { title: `next-app-router-${process.env.VARIANT || 'default'}`, } diff --git a/apps/next-app-router/app/page.tsx b/apps/next-app-router/app/page.tsx index 48128cfc..fd4cccdd 100644 --- a/apps/next-app-router/app/page.tsx +++ b/apps/next-app-router/app/page.tsx @@ -16,6 +16,8 @@ import Variant from './Variant' import { PreviewTable, PreviewFooter } from './previews' import { Suspense } from 'react' +export const runtime = 'edge' + export default async function Page() { const footer = await sanityFetch({ query: footerQuery, @@ -32,6 +34,7 @@ export default async function Page() { initialData={footer} query={footerQuery} as={PreviewFooter} + throwOnMissingProvider={false} >