Skip to content

Commit

Permalink
Merge branch 'canary' into test-test-next-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] committed Sep 11, 2023
2 parents 42b004e + 40da1ae commit 44881ad
Show file tree
Hide file tree
Showing 61 changed files with 338 additions and 494 deletions.
485 changes: 157 additions & 328 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions Cargo.toml
Expand Up @@ -38,16 +38,15 @@ next-transform-dynamic = { path = "packages/next-swc/crates/next-transform-dynam
next-transform-strip-page-exports = { path = "packages/next-swc/crates/next-transform-strip-page-exports" }

# SWC crates
# Keep consistent with preset_env_base through swc_core
swc_core = { version = "0.82.11" }
testing = { version = "0.34.1" }
swc_core = { version = "=0.79.55", features = ["ecma_loader_lru", "ecma_loader_parking_lot"] }
testing = { version = "0.33.21" }

# Turbo crates
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230901.3" }
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230908.2" }
# [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros..
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230901.3" }
turbo-tasks= { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230908.2" }
# [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230901.3" }
turbo-tasks-fs= { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230908.2" }

# General Deps

Expand Down
Expand Up @@ -177,19 +177,21 @@ For [`getStaticProps`](/docs/pages/api-reference/functions/get-static-props), [`
```tsx filename="pages/blog/[slug].tsx"
import { GetStaticProps, GetStaticPaths, GetServerSideProps } from 'next'

export const getStaticProps: GetStaticProps = async (context) => {
export const getStaticProps = (async (context) => {
// ...
}
}) satisfies GetStaticProps

export const getStaticPaths: GetStaticPaths = async () => {
export const getStaticPaths = (async () => {
// ...
}
}) satisfies GetStaticPaths

export const getServerSideProps: GetServerSideProps = async (context) => {
export const getServerSideProps = (async (context) => {
// ...
}
}) satisfies GetServerSideProps
```

> **Good to know:** `satisfies` was added to TypeScript in [4.9](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-9.html). We recommend upgrading to the latest version of TypeScript.
## API Routes

The following is an example of how to use the built-in types for API routes:
Expand Down
Expand Up @@ -16,33 +16,33 @@ There are several reasons why you might want to switch from Vite to Next.js:
happens due to a couple of reasons:
1. The browser needs to wait for the React code and your entire application bundle to download
and run before your code is able to send requests to load some data.
1. Your application code grows with every new feature and extra dependency you add.
1. **No automatic code splitting**: The previous issue of slow loading times can be somewhat managed with code splitting.
2. Your application code grows with every new feature and extra dependency you add.
2. **No automatic code splitting**: The previous issue of slow loading times can be somewhat managed with code splitting.
However, if you try to do code splitting manually, you'll often make performance worse. It's easy
to inadvertently introduce network waterfalls when code-splitting manually. Next.js provides
automatic code splitting built into its router.
1. **Network waterfalls**: A common cause of poor performance occurs when applications make
3. **Network waterfalls**: A common cause of poor performance occurs when applications make
sequential client-server requests to fetch data. One common pattern for data fetching in an SPA
is to initially render a placeholder, and then fetch data after the component has mounted.
Unfortunately, this means that a child component that fetches data can't start fetching until
the parent component has finished loading its own data. On Next.js,
[this issue is resolved](https://github.com/reactjs/rfcs/blob/main/text/0188-server-components.md#no-client-server-waterfalls)
by fetching data in Server Components.
1. **Fast and intentional loading states**: Thanks to built-in support for
4. **Fast and intentional loading states**: Thanks to built-in support for
[Streaming with Suspense](/docs/app/building-your-application/routing/loading-ui-and-streaming#streaming-with-suspense),
with Next.js, you can be more intentional about which parts of your UI you want to load first and
in what order without introducing network waterfalls. This enables you to build pages that are
faster to load and also eliminate [layout shifts](https://web.dev/cls/).
1. **Choose the data fetching strategy**: Depending on your needs, Next.js allows you to choose your
5. **Choose the data fetching strategy**: Depending on your needs, Next.js allows you to choose your
data fetching strategy on a page and component basis. You can decide to fetch at build time, at
request time on the server, or on the client. For example, you can fetch data from your CMS and
render your blog posts at build time, which can then be efficiently cached on a CDN.
1. **Middleware**: [Next.js Middleware](/docs/app/building-your-application/routing/middleware)
6. **Middleware**: [Next.js Middleware](/docs/app/building-your-application/routing/middleware)
allows you to run code on the server before a request is completed. This is especially useful to
avoid having a flash of unauthenticated content when the user visits an authenticated-only page
by redirecting the user to a login page. The middleware is also useful for experimentation and
internationalization.
1. **Built-in Optimizations**: Images, fonts, and third-party scripts often have significant impact
7. **Built-in Optimizations**: Images, fonts, and third-party scripts often have significant impact
on an application's performance. Next.js comes with built-in components that automatically
optimize those for you.

Expand Down
Expand Up @@ -13,13 +13,13 @@ type Repo = {
stargazers_count: number
}

export const getStaticProps: GetStaticProps<{
repo: Repo
}> = async () => {
export const getStaticProps = (async (context) => {
const res = await fetch('https://api.github.com/repos/vercel/next.js')
const repo = await res.json()
return { props: { repo } }
}
}) satisfies GetStaticProps<{
repo: Repo
}>

export default function Page({
repo,
Expand All @@ -29,7 +29,7 @@ export default function Page({
```

```jsx filename="pages/index.js" switcher
export const getStaticProps = async () => {
export async function getStaticProps() {
const res = await fetch('https://api.github.com/repos/vercel/next.js')
const repo = await res.json()
return { props: { repo } }
Expand Down
Expand Up @@ -19,7 +19,7 @@ type Repo = {
stargazers_count: number
}

export const getStaticPaths: GetStaticPaths = async () => {
export const getStaticPaths = (async () => {
return {
paths: [
{
Expand All @@ -30,15 +30,15 @@ export const getStaticPaths: GetStaticPaths = async () => {
],
fallback: true, // false or "blocking"
}
}
}) satisfies GetStaticPaths

export const getStaticProps: GetStaticProps<{
repo: Repo
}> = async () => {
export const getStaticProps = (async (context) => {
const res = await fetch('https://api.github.com/repos/vercel/next.js')
const repo = await res.json()
return { props: { repo } }
}
}) satisfies GetStaticProps<{
repo: Repo
}>

export default function Page({
repo,
Expand All @@ -48,7 +48,7 @@ export default function Page({
```

```jsx filename="pages/repo/[name].js" switcher
export const getStaticPaths = async () => {
export async function getStaticPaths() {
return {
paths: [
{
Expand All @@ -61,7 +61,7 @@ export const getStaticPaths = async () => {
}
}

export const getStaticProps = async () => {
export async function getStaticProps() {
const res = await fetch('https://api.github.com/repos/vercel/next.js')
const repo = await res.json()
return { props: { repo } }
Expand Down
Expand Up @@ -13,13 +13,13 @@ type Repo = {
stargazers_count: number
}

export const getServerSideProps: GetServerSideProps<{
repo: Repo
}> = async () => {
export const getServerSideProps = (async (context) => {
const res = await fetch('https://api.github.com/repos/vercel/next.js')
const repo = await res.json()
return { props: { repo } }
}
}) satisfies GetServerSideProps<{
repo: Repo
}>

export default function Page({
repo,
Expand All @@ -29,7 +29,7 @@ export default function Page({
```

```jsx filename="pages/index.js" switcher
export const getServerSideProps = async () => {
export async function getServerSideProps() {
const res = await fetch('https://api.github.com/repos/vercel/next.js')
const repo = await res.json()
return { props: { repo } }
Expand Down Expand Up @@ -99,10 +99,6 @@ This approach works well for user dashboard pages, for example. Because a dashbo
The following example shows how to fetch data at request time and pre-render the result.

```jsx
function Page({ data }) {
// Render data...
}

// This gets called on every request
export async function getServerSideProps() {
// Fetch data from external API
Expand All @@ -113,7 +109,9 @@ export async function getServerSideProps() {
return { props: { data } }
}

export default Page
export default function Page({ data }) {
// Render data...
}
```

## Caching with Server-Side Rendering (SSR)
Expand Down
Expand Up @@ -13,13 +13,13 @@ type Repo = {
stargazers_count: number
}

export const getServerSideProps: GetServerSideProps<{
repo: Repo
}> = async () => {
export const getServerSideProps = (async (context) => {
const res = await fetch('https://api.github.com/repos/vercel/next.js')
const repo = await res.json()
return { props: { repo } }
}
}) satisfies GetServerSideProps<{
repo: Repo
}>

export default function Page({
repo,
Expand All @@ -29,7 +29,7 @@ export default function Page({
```

```jsx filename="pages/index.js" switcher
export const getServerSideProps = async () => {
export async function getServerSideProps() {
const res = await fetch('https://api.github.com/repos/vercel/next.js')
const repo = await res.json()
return { props: { repo } }
Expand Down
16 changes: 8 additions & 8 deletions docs/03-pages/02-api-reference/02-functions/get-static-paths.mdx
Expand Up @@ -17,7 +17,7 @@ type Repo = {
stargazers_count: number
}

export const getStaticPaths: GetStaticPaths = async () => {
export const getStaticPaths = (async () => {
return {
paths: [
{
Expand All @@ -28,15 +28,15 @@ export const getStaticPaths: GetStaticPaths = async () => {
],
fallback: true, // false or "blocking"
}
}
}) satisfies GetStaticPaths

export const getStaticProps: GetStaticProps<{
repo: Repo
}> = async () => {
export const getStaticProps = (async (context) => {
const res = await fetch('https://api.github.com/repos/vercel/next.js')
const repo = await res.json()
return { props: { repo } }
}
}) satisfies GetStaticProps<{
repo: Repo
}>

export default function Page({
repo,
Expand All @@ -46,7 +46,7 @@ export default function Page({
```

```jsx filename="pages/repo/[name].js" switcher
export const getStaticPaths = async () => {
export async function getStaticPaths() {
return {
paths: [
{
Expand All @@ -59,7 +59,7 @@ export const getStaticPaths = async () => {
}
}

export const getStaticProps = async () => {
export async function getStaticProps() {
const res = await fetch('https://api.github.com/repos/vercel/next.js')
const repo = await res.json()
return { props: { repo } }
Expand Down
10 changes: 5 additions & 5 deletions docs/03-pages/02-api-reference/02-functions/get-static-props.mdx
Expand Up @@ -13,13 +13,13 @@ type Repo = {
stargazers_count: number
}

export const getStaticProps: GetStaticProps<{
repo: Repo
}> = async () => {
export const getStaticProps = (async (context) => {
const res = await fetch('https://api.github.com/repos/vercel/next.js')
const repo = await res.json()
return { props: { repo } }
}
}) satisfies GetStaticProps<{
repo: Repo
}>

export default function Page({
repo,
Expand All @@ -29,7 +29,7 @@ export default function Page({
```

```jsx filename="pages/index.js" switcher
export const getStaticProps = async () => {
export async function getStaticPaths() {
const res = await fetch('https://api.github.com/repos/vercel/next.js')
const repo = await res.json()
return { props: { repo } }
Expand Down
2 changes: 1 addition & 1 deletion examples/cms-builder-io/package.json
Expand Up @@ -6,7 +6,7 @@
"start": "next start"
},
"dependencies": {
"@builder.io/react": "^1.1.47",
"@builder.io/react": "^2.0.0",
"@builder.io/widgets": "^1.2.21",
"classnames": "2.3.1",
"date-fns": "2.28.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/cms-keystonejs-embedded/package.json
Expand Up @@ -7,8 +7,8 @@
"start": "next start"
},
"dependencies": {
"@keystone-next/fields": "^9.0.0",
"@keystone-next/keystone": "^18.0.0",
"@keystone-next/fields": "^15.0.0",
"@keystone-next/keystone": "^25.0.0",
"next": "10.2.2",
"react": "18.2.0",
"react-dom": "18.2.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/cms-makeswift/package.json
Expand Up @@ -6,7 +6,7 @@
"start": "next start"
},
"dependencies": {
"@makeswift/runtime": "0.2.2",
"@makeswift/runtime": "0.10.13",
"next": "latest",
"react": "18.2.0",
"react-dom": "18.2.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/with-recoil/package.json
Expand Up @@ -9,6 +9,6 @@
"next": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"recoil": "0.7.6"
"recoil": "0.7.7"
}
}
2 changes: 1 addition & 1 deletion lerna.json
Expand Up @@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "13.4.20-canary.21"
"version": "13.4.20-canary.23"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "13.4.20-canary.21",
"version": "13.4.20-canary.23",
"keywords": [
"react",
"next",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-next/package.json
@@ -1,6 +1,6 @@
{
"name": "eslint-config-next",
"version": "13.4.20-canary.21",
"version": "13.4.20-canary.23",
"description": "ESLint configuration used by Next.js.",
"main": "index.js",
"license": "MIT",
Expand All @@ -10,7 +10,7 @@
},
"homepage": "https://nextjs.org/docs/app/building-your-application/configuring/eslint#eslint-config",
"dependencies": {
"@next/eslint-plugin-next": "13.4.20-canary.21",
"@next/eslint-plugin-next": "13.4.20-canary.23",
"@rushstack/eslint-patch": "^1.3.3",
"@typescript-eslint/parser": "^5.4.2 || ^6.0.0",
"eslint-import-resolver-node": "^0.3.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "13.4.20-canary.21",
"version": "13.4.20-canary.23",
"description": "ESLint plugin for NextJS.",
"main": "dist/index.js",
"license": "MIT",
Expand Down

0 comments on commit 44881ad

Please sign in to comment.