Skip to content

Commit

Permalink
Merge branch 'canary' into not-found-default
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi authored Aug 28, 2023
2 parents 878ca82 + 0f82237 commit 80bf6b1
Show file tree
Hide file tree
Showing 257 changed files with 30,262 additions and 765 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,13 @@ jobs:
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}

- name: Cache on ${{ github.ref_name }}
uses: ijjk/[email protected]
with:
shared-key: build-${{ matrix.settings.target }}
save-if: 'true'
cache-provider: 'turbo'

# we only need custom caching for docker builds
# as they are on an older Node.js version and have
# issues with turbo caching
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/build_reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ on:
required: false
description: 'if test trace needs uploading'
type: string
rustCacheKey:
required: false
description: 'rustCacheKey to cache shared target assets'
type: string

env:
NAPI_CLI_VERSION: 2.14.7
Expand Down Expand Up @@ -114,6 +118,14 @@ jobs:

- run: corepack prepare --activate [email protected] && npm i -g "turbo@${TURBO_VERSION}" "@napi-rs/cli@${NAPI_CLI_VERSION}"

- name: Cache on ${{ github.ref_name }}
uses: ijjk/[email protected]
if: ${{ inputs.rustCacheKey }}
with:
shared-key: ${{ inputs.rustCacheKey }}-x86_64-unknown-linux-gnu
save-if: ${{ github.ref_name == 'canary' }}
cache-provider: 'turbo'

# clean up any previous artifacts to avoid hitting disk space limits
- run: git clean -xdf && rm -rf /tmp/next-repo-*; rm -rf /tmp/next-install-* /tmp/yarn-* /tmp/ncc-cache target

Expand Down
4 changes: 2 additions & 2 deletions bench/nested-deps-app-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "bench-nested-deps-app-router",
"scripts": {
"prepare-bench": "rimraf components && fuzzponent -d 2 -s 206 -o components",
"dev": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 next dev",
"dev-application": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 next dev",
"build-application": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 next build",
"start": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 next start",
"dev-nocache": "rimraf .next && pnpm dev",
"dev-nocache": "rimraf .next && pnpm dev-application",
"dev-cpuprofile-nocache": "rimraf .next && cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 node --cpu-prof ../../node_modules/next/dist/bin/next",
"build-nocache": "rimraf .next && pnpm build-application"
},
Expand Down
4 changes: 2 additions & 2 deletions bench/nested-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "bench-nested-deps",
"scripts": {
"prepare-bench": "rimraf components && fuzzponent -d 2 -s 206 -o components",
"dev": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 next dev",
"dev-application": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 next dev",
"build-application": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 next build",
"start": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 next start",
"dev-nocache": "rimraf .next && pnpm dev",
"dev-nocache": "rimraf .next && pnpm dev-application",
"dev-cpuprofile-nocache": "rimraf .next && cross-env NEXT_PRIVATE_LOCAL_WEBPACK=1 node --cpu-prof ../../node_modules/next/dist/bin/next",
"build-nocache": "rimraf .next && pnpm build-application"
},
Expand Down
1 change: 0 additions & 1 deletion bench/readdir/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions bench/readdir/create-fixtures.sh

This file was deleted.

24 changes: 0 additions & 24 deletions bench/readdir/glob.js

This file was deleted.

21 changes: 0 additions & 21 deletions bench/readdir/recursive-readdir.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ If you have multiple fetch requests in a statically rendered route, and each has

Learn more about [time-based revalidation](/docs/app/building-your-application/caching#time-based-revalidation).

> **Good to know:** Revalidation only works with the [Node.js runtime](/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes#nodejs-runtime) (default).
#### On-demand Revalidation

Data can be revalidated on-demand by path ([`revalidatePath`](/docs/app/api-reference/functions/revalidatePath)) or by cache tag ([`revalidateTag`](/docs/app/api-reference/functions/revalidateTag)) inside a Route Handler or a Server Action.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,17 @@ export default async function submit() {
}
```

```js filename="app/actions.js" switcher
'use server'

import { revalidatePath } from 'next/cache'

export default async function submit() {
await submitForm()
revalidatePath('/')
}
```

Or invalidate a specific data fetch with a cache tag using [`revalidateTag`](/docs/app/api-reference/functions/revalidateTag):

```ts filename="app/actions.ts" switcher
Expand All @@ -198,6 +209,17 @@ export default async function submit() {
}
```

```js filename="app/actions.js" switcher
'use server'

import { revalidateTag } from 'next/cache'

export default async function submit() {
await addPost()
revalidateTag('posts')
}
```

</AppOnly>

### Redirecting
Expand Down Expand Up @@ -244,6 +266,19 @@ export default async function submit() {
}
```

```js filename="app/actions.js" switcher
'use server'

import { redirect } from 'next/navigation'
import { revalidateTag } from 'next/cache'

export default async function submit() {
const id = await addPost()
revalidateTag('posts') // Update cached posts
redirect(`/post/${id}`) // Navigate to new route
}
```

</AppOnly>

### Form Validation
Expand Down Expand Up @@ -740,7 +775,18 @@ You can set cookies inside a Server Action using the [`cookies`](/docs/app/api-r
import { cookies } from 'next/headers'

export async function create() {
const cart = await createCart():
const cart = await createCart()
cookies().set('cartId', cart.id)
}
```

```js filename="app/actions.js" switcher
'use server'

import { cookies } from 'next/headers'

export async function create() {
const cart = await createCart()
cookies().set('cartId', cart.id)
}
```
Expand Down Expand Up @@ -789,6 +835,17 @@ export async function create() {
}
```

```js filename="app/actions.js" switcher
'use server'

import { cookies } from 'next/headers'

export async function create() {
const auth = cookies().get('authorization')?.value
// ...
}
```
</AppOnly>
### Deleting Cookies
Expand Down Expand Up @@ -833,6 +890,17 @@ export async function create() {
}
```
```js filename="app/actions.js" switcher
'use server'

import { cookies } from 'next/headers'

export async function create() {
cookies().delete('name')
// ...
}
```
See [additional examples](/docs/app/api-reference/functions/cookies#deleting-cookies) for deleting cookies from Server Actions.
</AppOnly>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ There are many considerations to make when choosing a runtime. This table shows
| Security | Normal | High | High |
| Latency | Normal | Low | Lowest |
| npm Packages | All | All | A smaller subset |
| Revalidation | Yes | Yes | No |
| [Static Rendering](/docs/app/building-your-application/rendering/server-components#static-rendering-default) | Yes | Yes | No |
| [Dynamic Rendering](/docs/app/building-your-application/rendering/server-components#dynamic-rendering) | Yes | Yes | Yes |
| [Data Revalidation w/ `fetch`](/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#revalidating-data) | Yes | Yes | Yes |

### Edge Runtime

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ See the [`cookies`](/docs/app/api-reference/functions/cookies) API reference.

### Segment Config Options

The Route Segment Config options can be used override the route segment defaults or when you're not able to use the `fetch` API (e.g. database client or 3rd party libraries).
The Route Segment Config options can be used to override the route segment defaults or when you're not able to use the `fetch` API (e.g. database client or 3rd party libraries).

The following Route Segment Config options will opt out of the Data Cache and Full Route Cache:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type Props = {

export async function generateMetadata(
{ params, searchParams }: Props,
parent?: ResolvingMetadata
parent: ResolvingMetadata
): Promise<Metadata> {
// read route params
const id = params.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: revalidateTag
description: API Reference for the revalidateTag function.
---

`revalidatePath` allows you to purge [cached data](/docs/app/building-your-application/caching) on-demand for a specific cache tag.
`revalidateTag` allows you to purge [cached data](/docs/app/building-your-application/caching) on-demand for a specific cache tag.

> **Good to know**:
>
Expand Down
60 changes: 60 additions & 0 deletions examples/cms-sitecore-xmcloud/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Read the Vercel + Sitecore docs for the full setup instructions: https://vercel.com/docs/integrations/sitecore

# For development purposes, note Next.js supports a .env.local
# file, which is already configured to be git ignored.
# Read more about Next.js support of environment variables here:
# https://nextjs.org/docs/basic-features/environment-variables
JSS_APP_NAME=

# The public URL to use for absolute URLs, which are required when
# the Next.js app is run within Sitecore editors.
# This should match the `serverSideRenderingEngineApplicationUrl`
# in your Sitecore configuration (see \sitecore\config\xmcloud-nextjs-starter.config).
# Be sure to update these values accordingly as your public endpoint changes.
# See https://jss.sitecore.com/docs/fundamentals/services/view-engine
PUBLIC_URL=http://localhost:3000

# To secure the Sitecore editor endpoint exposed by your Next.js app
# (`/api/editing/render` by default), a secret token is used. This (client-side)
# value must match your server-side value (see \sitecore\config\xmcloud-nextjs-starter.config).
# We recommend an alphanumeric value of at least 16 characters.
JSS_EDITING_SECRET=

# Your Sitecore API key is needed to build the app. Typically, the API key is
# defined in `scjssconfig.json` (as `sitecore.apiKey`). This file may not exist
# when building locally (if you've never run `jss setup`), or when building in a
# higher environment (since `scjssconfig.json` is ignored from source control).
# In this case, use this environment variable to provide the value at build time.
SITECORE_API_KEY=

# Your Sitecore API hostname is needed to build the app. Typically, the API host is
# defined in `scjssconfig.json` (as `sitecore.layoutServiceHost`). This file may
# not exist when building locally (if you've never run `jss setup`), or when building
# in a higher environment (since `scjssconfig.json` is ignored from source control).
# In this case, use this environment variable to provide the value at build time.
SITECORE_API_HOST=

# Your GraphQL Edge endpoint. This is required for Sitecore Experience Edge.
# For Sitecore XM, this is typically optional. By default, the endpoint is calculated using
# the resolved Sitecore API hostname + the `graphQLEndpointPath` defined in your `package.json`.
GRAPH_QL_ENDPOINT=

# Your default app language.
DEFAULT_LANGUAGE=

# The way in which layout and dictionary data is fetched from Sitecore
FETCH_WITH=GraphQL

# Indicates whether SSG `getStaticPaths` pre-render any pages
# Set the environment variable DISABLE_SSG_FETCH=true
# to enable full ISR (Incremental Static Regeneration) flow
DISABLE_SSG_FETCH=

# Sitecore JSS npm packages utilize the debug module for debug logging.
# https://www.npmjs.com/package/debug
# Set the DEBUG environment variable to 'sitecore-jss:*' to see all logs:
#DEBUG=sitecore-jss:*
# Or be selective and show for example only layout service logs:
#DEBUG=sitecore-jss:layout
# Or everything BUT layout service logs:
#DEBUG=sitecore-jss:*,-sitecore-jss:layout
33 changes: 33 additions & 0 deletions examples/cms-sitecore-xmcloud/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
/node_modules

# testing
/coverage

# next.js
/.next*/
/out/

# graphql code generation
/.generated
*.graphql.d.ts
*.graphqls.d.ts

# misc
.DS_Store

# local env files
.env.local
.env.*.local

# Log files
*.log*

# sitecore
scjssconfig.json
*.deploysecret.config

# vercel
.vercel
8 changes: 8 additions & 0 deletions examples/cms-sitecore-xmcloud/.graphql-let.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
schema:
- './src/temp/GraphQLIntrospectionResult.json'
documents: 'src/**/*.graphql'
plugins:
- typescript-operations
- typed-document-node
config:
useIndexSignature: true
Loading

0 comments on commit 80bf6b1

Please sign in to comment.