Skip to content

Commit

Permalink
Merge branch 'canary' into middleware-request-headers-manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
nuta committed Oct 19, 2022
2 parents 664e101 + 3e2aec5 commit 0f4ffdd
Show file tree
Hide file tree
Showing 1,190 changed files with 141,276 additions and 11,034 deletions.
Expand Up @@ -16,7 +16,10 @@ function loadStatsConfig() {
'stats-config.js'
))
break
} catch (_) {
} catch (err) {
if (err.code !== 'MODULE_NOT_FOUND') {
console.error('Failed to load stats-config at', configPath, err)
}
/* */
}
}
Expand Down
49 changes: 0 additions & 49 deletions .github/actions/next-stats-action/src/run/index.js
Expand Up @@ -169,55 +169,6 @@ async function runConfigs(
)
)
curStats.General.buildDurationCached = Date.now() - secondBuildStart

if (statsConfig.appDevCommand) {
const port = await getPort()
const startTime = Date.now()
const child = exec.spawn(statsConfig.appDevCommand, {
cwd: statsAppDir,
env: {
PORT: port,
},
stdio: 'pipe',
})

let serverReadyResolve
let serverReadyResolved = false
const serverReadyPromise = new Promise((resolve) => {
serverReadyResolve = resolve
})

child.stdout.on('data', (data) => {
if (
data.toString().includes('started server') &&
!serverReadyResolved
) {
serverReadyResolved = true
serverReadyResolve()
}
process.stdout.write(data)
})
child.stderr.on('data', (data) => process.stderr.write(data))

child.on('exit', (code) => {
if (!serverReadyResolved) {
serverReadyResolve()
serverReadyResolved = true
}
exitCode = code
})

setTimeout(() => {
if (!serverReadyResolved) {
child.kill()
}
}, 3 * 1000)

await serverReadyPromise
child.kill()

curStats['General']['nextDevReadyDuration'] = Date.now() - startTime
}
}

logger(`Finished running: ${config.title}`)
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build_test_deploy.yml
Expand Up @@ -7,7 +7,7 @@ on:
name: Build, test, and deploy

env:
NAPI_CLI_VERSION: 2.7.0
NAPI_CLI_VERSION: 2.12.0
TURBO_VERSION: 1.3.2-canary.1
RUST_TOOLCHAIN: nightly-2022-09-23
PNPM_VERSION: 7.3.0
Expand Down Expand Up @@ -243,7 +243,7 @@ jobs:
name: Test Development
runs-on: ubuntu-latest
needs: [build, build-native-test]
timeout-minutes: 25
timeout-minutes: 30
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
Expand Down Expand Up @@ -364,7 +364,7 @@ jobs:
name: Test Development (E2E)
runs-on: ubuntu-latest
needs: [build, build-native-test]
timeout-minutes: 25
timeout-minutes: 30
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
Expand Down Expand Up @@ -709,7 +709,7 @@ jobs:
name: Test Integration
runs-on: ubuntu-latest
needs: [build, build-native-test]
timeout-minutes: 25
timeout-minutes: 30
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull_request_stats.yml
Expand Up @@ -5,7 +5,7 @@ on:
name: Generate Pull Request Stats

env:
NAPI_CLI_VERSION: 2.7.0
NAPI_CLI_VERSION: 2.12.0
TURBO_VERSION: 1.3.2-canary.1
RUST_TOOLCHAIN: nightly-2022-09-23
PNPM_VERSION: 7.3.0
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
# since the repo's dependencies aren't installed we need
# to install napi globally
- run: npm i -g @napi-rs/cli@2.7.0
- run: npm i -g @napi-rs/cli@${NAPI_CLI_VERSION}
- run: npm i -g turbo@${TURBO_VERSION} pnpm@${PNPM_VERSION}

- name: Build
Expand Down
116 changes: 115 additions & 1 deletion docs/advanced-features/codemods.md
Expand Up @@ -19,6 +19,30 @@ Codemods are transformations that run on your codebase programmatically. This al

## Next.js 13

### `new-link`

Safely removes `<a>` from `next/link` or adds `legacyBehavior` prop.

For example:

```jsx
export default function Page() {
return (
<Link href="/about">
<a>About Us</a>
</Link>
)
}
```

Transforms into:

```jsx
export default function Page() {
return <Link href="/about">About Us</Link>
}
```

### `next-image-to-legacy-image`

Safely migrates existing Next.js 10, 11, 12 applications importing `next/image` to the renamed `next/legacy/image` import in Next.js 13.
Expand Down Expand Up @@ -64,7 +88,97 @@ Dangerously migrates from `next/legacy/image` to the new `next/image` by adding
- Removes `objectPosition` prop and adds `style`
- Removes `lazyBoundary` prop
- Removes `lazyRoot` prop
- TODO: handle `loader`
- TODO: does not migrate the `loader` config. If you need it, you must manually add a `loader` prop.

#### Before: intrinsic

```jsx
import Image from 'next/image'
import img from '../img.png'

function Page() {
return <Image src={img} />
}
```

#### After: intrinsic

```jsx
import Image from 'next/image'
import img from '../img.png'

const css = { maxWidth: '100%', height: 'auto' }
function Page() {
return <Image src={img} style={css} />
}
```

#### Before: responsive

```jsx
import Image from 'next/image'
import img from '../img.png'

function Page() {
return <Image src={img} layout="responsive" />
}
```

#### After: responsive

```jsx
import Image from 'next/image'
import img from '../img.png'

const css = { width: '100%', height: 'auto' }
function Page() {
return <Image src={img} sizes="100vw" style={css} />
}
```

#### Before: fill

```jsx
import Image from 'next/image'
import img from '../img.png'

function Page() {
return <Image src={img} layout="fill" />
}
```

#### After: fill

```jsx
import Image from 'next/image'
import img from '../img.png'

function Page() {
return <Image src={img} sizes="100vw" fill />
}
```

#### Before: fixed

```jsx
import Image from 'next/image'
import img from '../img.png'

function Page() {
return <Image src={img} layout="fixed" />
}
```

#### After: fixed

```jsx
import Image from 'next/image'
import img from '../img.png'

function Page() {
return <Image src={img} />
}
```

## Next.js 11

Expand Down
10 changes: 5 additions & 5 deletions docs/advanced-features/compiler.md
Expand Up @@ -9,6 +9,7 @@ description: Learn about the Next.js Compiler, written in Rust, which transforms

| Version | Changes |
| --------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `v13.0.0` | SWC Minifier enabled by default. |
| `v12.3.0` | SWC Minifier [stable](https://nextjs.org/blog/next-12-3#swc-minifier-stable). |
| `v12.2.0` | [SWC Plugins](#swc-plugins-Experimental) experimental support added. |
| `v12.1.0` | Added support for Styled Components, Jest, Relay, Remove React Properties, Legacy Decorators, Remove Console, and jsxImportSource. |
Expand Down Expand Up @@ -241,18 +242,18 @@ Only `importMap` in `@emotion/babel-plugin` is not supported for now.

### Minification

You can opt-in to using the Next.js compiler for minification. This is 7x faster than Terser.
Next.js' swc compiler is used for minification by default since v13. This is 7x faster than Terser.

If Terser is still needed for any reason this can be configured.

```js
// next.config.js

module.exports = {
swcMinify: true,
swcMinify: false,
}
```

If you have feedback about `swcMinify`, please share it on the [feedback discussion](https://github.com/vercel/next.js/discussions/30237).

## Experimental Features

### Minifier debug options
Expand All @@ -271,7 +272,6 @@ module.exports = {
},
},
},
swcMinify: true,
}
```

Expand Down
4 changes: 2 additions & 2 deletions docs/advanced-features/i18n-routing.md
Expand Up @@ -233,7 +233,7 @@ import Link from 'next/link'
export default function IndexPage(props) {
return (
<Link href="/another" locale="fr">
<a>To /fr/another</a>
To /fr/another
</Link>
)
}
Expand Down Expand Up @@ -279,7 +279,7 @@ import Link from 'next/link'
export default function IndexPage(props) {
return (
<Link href="/fr/another" locale={false}>
<a>To /fr/another</a>
To /fr/another
</Link>
)
}
Expand Down
5 changes: 4 additions & 1 deletion docs/advanced-features/using-mdx.md
Expand Up @@ -16,7 +16,7 @@ However, because markdown is essentially static content, you can't create _dynam

## MDX Plugins

Internally MDX uses remark and rehype. Remark is a markdown processor powered by a plugins ecosystem. This plugin ecosystem lets you parse code, transform `HTML` elements, change syntax, extract frontmatter, and more.
Internally MDX uses remark and rehype. Remark is a markdown processor powered by a plugins ecosystem. This plugin ecosystem lets you parse code, transform `HTML` elements, change syntax, extract frontmatter, and more. Using [remark-gfm to enable GitHub flavored markdown (GFM)](https://mdxjs.com/guides/gfm/) is a popular option.

Rehype is an `HTML` processor, also powered by a plugin ecosystem. Similar to remark, these plugins let you manipulate, sanitize, compile and configure all types of data, elements and content.

Expand Down Expand Up @@ -44,6 +44,9 @@ The following steps outline how to setup `@next/mdx` in your Next.js project:
const withMDX = require('@next/mdx')({
extension: /\.mdx?$/,
options: {
// If you use remark-gfm, you'll need to use next.config.mjs
// as the package is ESM only
// https://github.com/remarkjs/remark-gfm#install
remarkPlugins: [],
rehypePlugins: [],
// If you use `MDXProvider`, uncomment the following line.
Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/data-fetching/get-static-props.md
Expand Up @@ -147,7 +147,7 @@ Files can be read directly from the filesystem in `getStaticProps`.

In order to do so you have to get the full path to a file.

Since Next.js compiles your code into a separate directory you can't use `__dirname` as the path it will return will be different from the pages directory.
Since Next.js compiles your code into a separate directory you can't use `__dirname` as the path it returns will be different from the pages directory.

Instead you can use `process.cwd()` which gives you the directory where Next.js is being executed.

Expand Down
4 changes: 1 addition & 3 deletions docs/api-reference/next.config.js/basepath.md
Expand Up @@ -35,9 +35,7 @@ For example, using `/about` will automatically become `/docs/about` when `basePa
export default function HomePage() {
return (
<>
<Link href="/about">
<a>About Page</a>
</Link>
<Link href="/about">About Page</Link>
</>
)
}
Expand Down

0 comments on commit 0f4ffdd

Please sign in to comment.