Skip to content

Commit

Permalink
Merge branch 'canary' into wyattjoh/pages-error-rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
wyattjoh authored Jun 19, 2023
2 parents f01fa79 + 3ca833d commit d0a29f7
Show file tree
Hide file tree
Showing 273 changed files with 6,925 additions and 954 deletions.
4 changes: 4 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ CARGO_WORKSPACE_DIR = { value = "", relative = true }

rustdocflags = []

[target.x86_64-unknown-linux-gnu]
# Should be kept in sync with turbopack's linker
rustflags = ["-C", "link-arg=-fuse-ld=mold"]

[target.x86_64-pc-windows-msvc]
linker = "rust-lld"

Expand Down
2 changes: 1 addition & 1 deletion .github/actions/next-stats-action/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN ln $(which python3) /usr/bin/python
RUN curl -sfLS https://install-node.vercel.app/v18 | bash -s -- -f

# Install node_modules
RUN npm i -g pnpm@7.24.3 [email protected]
RUN npm i -g pnpm@7.32.2 [email protected]
RUN cd /next-stats && pnpm install --production

RUN git config --global user.email 'stats@localhost'
Expand Down
6 changes: 6 additions & 0 deletions .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ runs:
echo CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse >> $GITHUB_ENV
fi
- shell: bash
run: |
: install mold linker
sudo apt update
sudo apt install -y mold
- name: 'Setup Rust toolchain'
uses: dtolnay/rust-toolchain@master
if: ${{ !inputs.skip-install }}
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
env:
NAPI_CLI_VERSION: 2.14.7
TURBO_VERSION: 1.9.6
PNPM_VERSION: 7.24.3
PNPM_VERSION: 7.32.2
NODE_MAINTENANCE_VERSION: 16
NODE_LTS_VERSION: 18

Expand Down Expand Up @@ -418,6 +418,7 @@ jobs:
NEXT_TELEMETRY_DISABLED: 1
VERCEL_TEST_TOKEN: ${{ secrets.VERCEL_TEST_TOKEN }}
VERCEL_TEST_TEAM: vtest314-next-e2e-tests
DATADOG_API_KEY: ${{ secrets.DATA_DOG_API_KEY }}
steps:
- uses: actions/cache@v3
timeout-minutes: 5
Expand All @@ -436,7 +437,7 @@ jobs:
- run: RESET_VC_PROJECT=true node scripts/reset-vercel-project.mjs
name: Reset test project

- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-jammy /bin/bash -c "cd /work && NODE_VERSION=${{ env.NODE_LTS_VERSION }} ./scripts/setup-node.sh && npm i -g pnpm@${PNPM_VERSION} > /dev/null && VERCEL_TEST_TOKEN=${{ secrets.VERCEL_TEST_TOKEN }} VERCEL_TEST_TEAM=vtest314-next-e2e-tests NEXT_TEST_JOB=1 NEXT_TEST_MODE=deploy TEST_TIMINGS_TOKEN=${{ secrets.TEST_TIMINGS_TOKEN }} NEXT_TEST_CONTINUE_ON_ERROR=1 xvfb-run node run-tests.js --type e2e >> /proc/1/fd/1"
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-jammy /bin/bash -c "cd /work && NODE_VERSION=${{ env.NODE_LTS_VERSION }} ./scripts/setup-node.sh && npm i -g pnpm@${PNPM_VERSION} > /dev/null && DATADOG_TRACE_NEXTJS_TEST=TRUE DATADOG_API_KEY=${DATADOG_API_KEY} DD_ENV=ci VERCEL_TEST_TOKEN=${{ secrets.VERCEL_TEST_TOKEN }} VERCEL_TEST_TEAM=vtest314-next-e2e-tests NEXT_TEST_JOB=1 NEXT_TEST_MODE=deploy TEST_TIMINGS_TOKEN=${{ secrets.TEST_TIMINGS_TOKEN }} NEXT_TEST_CONTINUE_ON_ERROR=1 xvfb-run node run-tests.js --type e2e >> /proc/1/fd/1"
name: Run test/e2e (deploy)

- name: Upload test trace
Expand All @@ -449,6 +450,14 @@ jobs:
path: |
test/traces
- name: Upload test trace to datadog
continue-on-error: true
run: |
ls -al ./test
npm install -g [email protected] @datadog/[email protected]
jrm ./nextjs-test-result-junit.xml "test/test-junit-report/**/*.xml"
DD_ENV=ci datadog-ci junit upload --tags test.type:nextjs_deploy_e2e --service nextjs ./nextjs-test-result-junit.xml
releaseStats:
name: Release Stats
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
env:
NAPI_CLI_VERSION: 2.14.7
TURBO_VERSION: 1.9.6
PNPM_VERSION: 7.24.3
PNPM_VERSION: 7.32.2
NODE_MAINTENANCE_VERSION: 16
NODE_LTS_VERSION: 18
TEST_CONCURRENCY: 6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ on:
env:
NAPI_CLI_VERSION: 2.14.7
TURBO_VERSION: 1.9.6
PNPM_VERSION: 7.24.3
PNPM_VERSION: 7.32.2
NODE_MAINTENANCE_VERSION: 16
NODE_LTS_VERSION: 18
TEST_CONCURRENCY: 6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull_request_stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: Generate Pull Request Stats
env:
NAPI_CLI_VERSION: 2.14.7
TURBO_VERSION: 1.9.6
PNPM_VERSION: 7.24.3
PNPM_VERSION: 7.32.2
NODE_MAINTENANCE_VERSION: 16
NODE_LTS_VERSION: 18
TEST_CONCURRENCY: 6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
name: Test examples

env:
PNPM_VERSION: 7.24.3
PNPM_VERSION: 7.32.2

jobs:
testExamples:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trigger_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ name: Trigger Release
env:
NAPI_CLI_VERSION: 2.14.7
TURBO_VERSION: 1.9.6
PNPM_VERSION: 7.24.3
PNPM_VERSION: 7.32.2
NODE_MAINTENANCE_VERSION: 16
NODE_LTS_VERSION: 18

Expand Down
30 changes: 30 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pr:

variables:
PNPM_CACHE_FOLDER: $(Pipeline.Workspace)/.pnpm-store
PNPM_VERSION: 7.24.3
PNPM_VERSION: 7.32.2
NEXT_TELEMETRY_DISABLED: '1'
node_16_version: ^16.8.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export async function POST() {
}
```

> **Good to know**: Previously, API Routes could have been used for use cases like handling form submissions. Route Handlers are likely not the solution for these uses cases. We will be recommending the use of [mutations](/docs/app/building-your-application/data-fetching/server-actions) for this when ready.
> **Good to know**: Previously, API Routes could have been used for use cases like handling form submissions. Route Handlers are likely not the solution for these use cases. We will be recommending the use of [mutations](/docs/app/building-your-application/data-fetching/server-actions) for this when ready.
### Route Resolution

Expand Down Expand Up @@ -388,6 +388,60 @@ export async function GET(request, { params }) {

### Streaming

Streaming is commonly used in combination with Large Language Models (LLMs), such an OpenAI, for AI-generated content. Learn more about the [AI SDK](https://sdk.vercel.ai/docs).

```ts filename="app/api/completion/route.ts" switcher
import { Configuration, OpenAIApi } from 'openai-edge'
import { OpenAIStream, StreamingTextResponse } from 'ai'

const config = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
})
const openai = new OpenAIApi(config)

export const runtime = 'edge'

export async function POST(req: Request) {
const { prompt } = await req.json()
const response = await openai.createCompletion({
model: 'text-davinci-003',
stream: true,
temperature: 0.6,
prompt: 'What is Next.js?',
})

const stream = OpenAIStream(response)
return new StreamingTextResponse(stream)
}
```

```js filename="app/api/completion/route.js" switcher
import { Configuration, OpenAIApi } from 'openai-edge'
import { OpenAIStream, StreamingTextResponse } from 'ai'

const config = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
})
const openai = new OpenAIApi(config)

export const runtime = 'edge'

export async function POST(req) {
const { prompt } = await req.json()
const response = await openai.createCompletion({
model: 'text-davinci-003',
stream: true,
temperature: 0.6,
prompt: 'What is Next.js?',
})

const stream = OpenAIStream(response)
return new StreamingTextResponse(stream)
}
```

These abstractions use the Web APIs to create a stream. You can also use the underlying Web APIs directly.

```ts filename="app/api/route.ts" switcher
// https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream#convert_async_iterator_to_stream
function iteratorToStream(iterator: any) {
Expand Down
4 changes: 2 additions & 2 deletions docs/02-app/01-building-your-application/01-routing/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ In a nested route, the components of a segment will be nested **inside** the com

## Colocation

In addition to special files, you have the option to colocate your own files (e.g. components, styles, tests etc) inside folders in the `app` directory.
In addition to special files, you have the option to colocate your own files (e.g. components, styles, tests, etc) inside folders in the `app` directory.

This is because while folders define routes, only the contents returned by `page.js` or `route.js` are publically addressable.

Expand Down Expand Up @@ -172,7 +172,7 @@ Without partial rendering, each navigation would cause the full page to re-rende

## Advanced Routing Patterns

The App Router also provides a set conventions to help you implement more advanced routing patterns. These include:
The App Router also provides a set of conventions to help you implement more advanced routing patterns. These include:

- [Parallel Routes](/docs/app/building-your-application/routing/parallel-routes): Allow you to simultaneously show two or more pages in the same view that can be navigated independently. You can use them for split views that have their own sub-navigation. E.g. Dashboards.
- [Intercepting Routes](/docs/app/building-your-application/routing/intercepting-routes): Allow you to intercept a route and show it in the context of another route. You can use these when keeping the context for the current page is important. E.g. Seeing all tasks while editing one task or expanding a photo in a feed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ React 18 and Next.js 13 introduced new ways to render your application. This pag
There are two environments where your application code can be rendered: the client and the server.

<Image
alt="Client and Server Environemnts"
alt="Client and Server Environments"
srcLight="/docs/light/client-and-server-environments.png"
srcDark="/docs/dark/client-and-server-environments.png"
width="1600"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function AddToCart({ productId }) {
```jsx filename="app/actions.js" highlight={1, 3}
'use server'

async function addItem(data) {
export async function addItem(data) {
const cartId = cookies().get('cartId')?.value
await saveToDb({ cartId, data })
}
Expand Down Expand Up @@ -545,7 +545,7 @@ React also provides built-in solutions for [optimistic updates](#experimental-us
### Form Actions
[Actions](#actions) integrated into the web standard `<form>` API, and enable out-of-the-box progressive enhancement and [loading states](#experimental-useformstatus). Similar to the HTML primitive [`formaction`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#formation).
[Actions](#actions) integrated into the web standard `<form>` API, and enable out-of-the-box progressive enhancement and [loading states](#experimental-useformstatus). Similar to the HTML primitive [`formaction`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#formaction).
### Server Functions
Expand Down
Loading

0 comments on commit d0a29f7

Please sign in to comment.