Skip to content

Commit

Permalink
feat!: enable turbo mode for everyone
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Nov 29, 2023
1 parent e1aa64f commit ddc3389
Show file tree
Hide file tree
Showing 19 changed files with 61 additions and 491 deletions.
9 changes: 4 additions & 5 deletions apps/next-app-router/app/Variant.tsx
Original file line number Diff line number Diff line change
@@ -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 <DefaultVariant {...props} />
return <>{props.children}</>
case 'groq-store':
return <GroqStoreVariant {...props} />
case 'live-store':
Expand Down
2 changes: 2 additions & 0 deletions apps/next-app-router/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'}`,
}
Expand Down
4 changes: 3 additions & 1 deletion apps/next-app-router/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<FooterProps['data']>({
query: footerQuery,
Expand Down Expand Up @@ -46,7 +48,7 @@ async function ServerTable() {
query: tableQuery,
tags: ['pages'],
})

return (
<LiveQuery
enabled={draftMode().isEnabled}
Expand Down
2 changes: 1 addition & 1 deletion apps/next-app-router/app/variants/default/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default function DefaultVariant({ children }: React.PropsWithChildren) {
return children
return <>{children}</>
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export default function PreviewProvider({
client={client}
token={token}
logger={console}
cache={{ includeTypes: ['page'] }}
>
{children}
</LiveQueryProvider>
Expand Down
3 changes: 2 additions & 1 deletion apps/next-app-router/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const nextConfig = {
fullUrl: true,
},
},
reactStrictMode: true,
serverActions: true,
productionBrowserSourceMaps: true,
// Support Vercel Authentication protection
Expand All @@ -21,7 +22,7 @@ const nextConfig = {
},
{
key: 'Content-Security-Policy',
value: `frame-ancestors 'self' https://*.sanity.build`,
value: `frame-ancestors 'self' https://*.sanity.build http://localhost:3333`,
},
],
},
Expand Down
3 changes: 2 additions & 1 deletion apps/next-pages-router/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const nextConfig = {
fullUrl: true,
},
},
reactStrictMode: true,
productionBrowserSourceMaps: true,
// Support Vercel Authentication protection
async headers() {
Expand All @@ -20,7 +21,7 @@ const nextConfig = {
},
{
key: 'Content-Security-Policy',
value: `frame-ancestors 'self' https://*.sanity.build`,
value: `frame-ancestors 'self' https://*.sanity.build http://localhost:3333`,
},
],
},
Expand Down
6 changes: 3 additions & 3 deletions apps/remix/app/variants/live-store/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { SerializeFrom } from '@vercel/remix'
import { lazy } from 'react'
import { StrictMode, lazy } from 'react'

import type { loader } from '~/routes'

Expand All @@ -12,9 +12,9 @@ export default function LiveStoreVariant({
studioUrl,
}: SerializeFrom<typeof loader> & React.PropsWithChildren) {
return previewDrafts ? (
<PreviewProvider token={token!} studioUrl={studioUrl}>
<StrictMode><PreviewProvider token={token!} studioUrl={studioUrl}>
{children}
</PreviewProvider>
</PreviewProvider></StrictMode>
) : (
children
)
Expand Down
2 changes: 0 additions & 2 deletions packages/preview-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@
"singleQuote": true
},
"dependencies": {
"@sanity/eventsource": "5.0.1",
"@sanity/groq-store": "4.1.3",
"@sanity/preview-kit-compat": "1.0.1",
"@vercel/stega": "0.1.0",
"lru-cache": "10.1.0",
Expand Down
200 changes: 0 additions & 200 deletions packages/preview-kit/src/GroqStoreProvider/GroqStoreProvider.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions packages/preview-kit/src/GroqStoreProvider/index.ts

This file was deleted.

Loading

0 comments on commit ddc3389

Please sign in to comment.