Commit graph

16846 commits

Author SHA1 Message Date
Steven
032e8d0eb0
chore(ci): add pnpm workspace for github actions (#52976)
This creates a monorepo for each github action and ensures they all use pnpm.

You can install and build all with the following:

```
cd .github
pnpm i
pnpm -r build
```
2023-07-21 14:29:31 +00:00
Alex Kirszenberg
319353e86f
Increase timeout for 404 tests (#52998) 2023-07-21 13:59:41 +02:00
Tobias Koppers
1717d1e986
Turbopack: Refactoring module references (#52930)
### What?

see https://github.com/vercel/turbo/pull/5572

### Why?

### How?
2023-07-21 10:37:57 +00:00
Donny/강동윤
84820c900f
Update swc_core to v0.79.22 (#52945)
### What?

Update swc_core to `v0.79.22` and other SWC crates to the latest.
### Why?

This is for further next.js work: https://vercel.slack.com/archives/C02HY34AKME/p1689768597095499


### How?

Closes WEB-1299

turbopack counterpart: https://github.com/vercel/turbo/pull/5575

Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
2023-07-21 10:01:08 +00:00
Tobias Koppers
e88777267a
update Turbopack (#52986)
* https://github.com/vercel/turbo/pull/5567 <!-- Alex Kirszenberg -
Remove unnecessary ValueDebugFormat item, hide Vc field -->
* https://github.com/vercel/turbo/pull/5576 <!-- Alex Kirszenberg -
Extract shared HMR utils to their own modules/crates -->
* https://github.com/vercel/turbo/pull/5503 <!-- OJ Kwon -
feat(turbopack_core): define trait for diagnostics -->
* https://github.com/vercel/turbo/pull/5487 <!-- Will Binns-Smith -
turbopack-cli: modularize code to support turbopack build -->
* https://github.com/vercel/turbo/pull/5488 <!-- Will Binns-Smith -
turbopack-cli: implement `turbopack build` -->
* https://github.com/vercel/turbo/pull/5450 <!-- Leah - feat: async
modules / top level await -->

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-07-21 10:34:35 +02:00
JJ Kasper
728fd7572a
Update to latest version of turborepo (#52979)
x-ref: [slack
thread](https://vercel.slack.com/archives/C03LMQZL205/p1689895062566699?thread_ts=1688753294.342269&cid=C03LMQZL205)
2023-07-21 10:04:06 +02:00
Wyatt Johnson
205d3845d1
Move Pages API rendering into bundle (#52149)
Moves the rendering for Pages API routes into the bundle. This also implements the `routeModule` interface for both Pages and Pages API routes in the Turbopack output. This also fixes a bug where the order of the imports for `Document` and `App` were reversed in the Turbopack build.
2023-07-21 05:51:37 +00:00
JJ Kasper
f57eecde5e
Separate routing code from render servers (#52492)
This breaks out routing handling from `next-server`, `next-dev-server`,
and `base-server` so that these are only handling the "render" work and
eventually these will be deleted completely in favor of the bundling
work being done.

The `router` process and separate `render` processes are still
maintained here although will be investigated further in follow-up to
see if we can reduce the need for these.

We are also changing the `require-cache` IPC to a single call instead of
call per entry to reduce overhead and also de-dupes handling for
starting the server between the standalone server and normal server.

To maintain support for existing turbopack route resolving this
implements the new route resolving in place of the existing
`route-resolver` until the new nextturbo API is fully landed.

After these initial changes we should continue to eliminate non-render
related code from `next-server`, `base-server`, and `next-dev-server`.
2023-07-20 22:13:42 -07:00
vercel-release-bot
04ae5be8d0 v13.4.11 2023-07-21 04:28:14 +00:00
vercel-release-bot
5853258d19 v13.4.11-canary.2 2023-07-21 03:49:07 +00:00
JJ Kasper
d7335b75d1
Revert "Refine the not-found rendering process for app router" (#52977)
Reverts vercel/next.js#52790

Reverting temporarily as this breaks turbopack's not found handling due
to the app tree being generated there not having the necessary parallel
routes in the `_not-found` entry x-ref:
0df8aac935/packages/next-swc/crates/next-core/src/app_structure.rs (L677-L681)

x-ref:
https://github.com/vercel/next.js/actions/runs/5616458194/job/15220295829
2023-07-20 20:39:05 -07:00
vercel-release-bot
0df8aac935 v13.4.11-canary.1 2023-07-20 22:21:52 +00:00
JJ Kasper
e609e023ca
Fix build side-effects from third-parties package (#52969)
We shouldn't be generating src files during the build script as these
can break publishing.
2023-07-20 15:10:57 -07:00
Jimmy Lai
55eebefbab
app-router: prefetching tweaks (#52949)
This PR tries to address some feedback around prefetching, like in #49607, where they were some warnings because we were over prefetching.

The tweaks in this PR:
- if there are no loading boundary below, we don't prefetch the full page anymore. I made that change a while ago but I think it wasn't the original intent from @sebmarkbage. Fixing that now. So now, we will prefetch the page content until the nearest loading boundary, only if there is any.
- there's now a queue for limiting the number of concurrent prefetches. This is to not ruin the bandwidth for complex pages. Thanks @alvarlagerlof for that one.
- also, if the prefetch is in the queue when navigating, it will get bumped.
- bonus: fixes a bug where we were wrongly stripping headers in dev for static pages

Test plan:
<img width="976" alt="CleanShot 2023-07-20 at 17 53 43@2x" src="https://github.com/vercel/next.js/assets/11064311/2ea34419-c002-4aea-94df-57576e3ecb2e">
In the screenshot you can see that:
- only 5 requests at a time are authorised
- when I clicked on 15, it got prioritised in the queue (did not cancel the rest)
- the prefetch only included the content until the loading boundary




Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-07-20 21:46:38 +00:00
Jiachi Liu
cb24c555a6
Refine the not-found rendering process for app router (#52790)
### What

This PR changes the flow of not-found rendering process. 

### Why

`not-found.js` was rendered in two ways before:
* 1 is SSR rendering the not-found as 404
* 2 is triggering the error on RSC rendering then the error will be
preserved in inline flight data, on the client it will recover the error
and trigger the proper error boundary.

The solution has been through a jounery:
No top-level not found boundary -> introduce metadata API -> then we
create a top level root not found boundary -> then we delete it due to
duplicated rendering of root layout -> now this

So the solution before this PR is still having a root not found boundary
wrapped in the `AppRouter`, it's being used in a lot of places including
HMR. As we discovered it's doing duplicated rendering of root layout,
then we removed it and it started failing with rendering `not-found` but
missing root layout. In this PR we redesign the process.

### How

Now the rendering architecture looks like:

* For normal root not-found and certain level of not-found boundary
they're still covered by `LayoutRouter`
* For other error renderings including not-found
* Fully remove the top level not-found boundary, when it renders with
404 error it goes to render the fallback page
* During rendering the fallback page it will check if it should just
renders a 404 error page or render nothing and let the error from inline
flight data to trigger the error boundary

pseudo code
```
try {
  render AppRouter > PageComponent
} catch (err) {
  create ErrorComponent by determine err
  render AppRouter > ErrorComponent
}
```

In this way if the error is thrown from top-level like the page itself
or even from metadata, we can still catch them and render the proper
error page based on the error type.

The problematic is the HMR: introduces a new development mode meta tag
`<meta name="next-error">` to indicate it's 404 so that we don't do
refresh. This reverts the change brougt in #51637 as it will also has
the duplicated rendering problem for root layout if it's included in the
top level not found boundary.

Also fixes the root layout missing issue:

Fixes #52718
Fixes #52739

---------

Co-authored-by: Shu Ding <g@shud.in>
2023-07-20 14:12:06 -07:00
Cassidy Williams
7a0297c2d4
Change "publically" to "publicly" in the routing docs (#52966)
### What and why?

The word "publicly" should be spelled consistently across the documentation. It is spelled currently as "publically" in a few places.

### How?

Fixed the spelling!
2023-07-20 20:47:42 +00:00
Shu Ding
a96a9b0791
Fix client reference manifest for interception routes (#52961)
We have the logic to group the client compiler's entry names to make sure we generate one single manifest file for the page. This is complicated and requires a special step to "group" the entry names because a page can depend on a bunch of files from everywhere.

And currently, the normalization of "entryName → groupName" doesn't cover interception routes' conventions (`(.)`, `(..)` and `(...)`). This PR fixes that.

Closes #52862, closes #52681, closes #52958.
2023-07-20 20:06:44 +00:00
Jon Meyers
2b49741308
examples: export force-dynamic from all dynamic routes (#52916)
### What?

Stop `with-supabase` template from throwing errors on build

### Why?

Dynamic Routes now fail the build, rather than console.logging an error

### How?

Export the following from any routes that use the `cookies` function

```
export const dynamic = "force-dynamic";
```

Install `encoding` as a dev dependency until this is fixed downstream
2023-07-20 13:33:43 +00:00
Daryll J. Reillo
66f0983cb8
Update 06-lazy-loading.mdx: Incorrect filename in Example on "Importing Named Imports" (#52932)
The correct filename is seen on PagesOnly. But on AppOnly, the filename is not correct. It should be "hello" instead of "ClientComponent".

line to change:
from:
import('../components/ClientComponent').then((mod) => mod.Hello)

to:
import('../components/hello').then((mod) => mod.Hello)


line to change:
from:
import('../components/ClientComponent').then((mod) => mod.Hello)

to:
import('../components/hello').then((mod) => mod.Hello)
2023-07-20 12:57:18 +00:00
Darshan Jain
8e3cd83dc8
Allow general language codes in the Metadata API (#52920)
Closes #52898

LangCode Missing zh-Hans and zh-Hant

| 'yo-NG'
  | 'zh-CN'
  | 'zh-Hans'   //added
  | 'zh-Hant'        //added
  | 'zh-HK'
  | 'zh-MO'
  | 'zh-SG'
  | 'zh-TW'
  | 'zu-ZA'


f5272acbe5/packages/next/src/lib/metadata/types/alternative-urls-types.ts (L419)


Co-authored-by: Shu Ding <3676859+shuding@users.noreply.github.com>
2023-07-20 11:05:33 +00:00
Balázs Orbán
df0330f72e
chore: add GitHub Action to manage "+1" comments (#52866)
### What?

Adds a GitHub Action that automatically marks unhelpful comments as "off-topic".

You can test it by adding off-topic comments to this issue: https://github.com/balazsorban44/next.js/issues/21

17e3ec3068/.github/actions/minus-one/src/index.mjs (L6)

### Why?

A common problem is when an issue thread receives "+1" comments, it usually encourages others to do the same. This makes the thread harder and harder for maintainers to read, without adding value to the discussion.

### How?

When an issue receives a comment, we compare it to a list that we determine as off-topic. If it matches, we hide the comment.

See: https://docs.github.com/en/graphql/reference/mutations#minimizecomment
2023-07-20 09:34:29 +00:00
Tobias Koppers
840059415b
add edge support for next.rs API (#52885)
### What?

adds edge pages, apis, app pages and app routes to next.rs api

### Why?

### How?
2023-07-20 08:57:58 +00:00
Zack Tanner
8664ffe26d
fix: allow smooth scrolling if only hash changes (pages & app) (#52915)
We were preventing smooth scrolling to avoid jarring UX when `scroll-behavior: smooth` was set and the user navigates to another route ([PR](https://github.com/vercel/next.js/pull/40642) and [related comment](https://github.com/vercel/next.js/issues/51721#issuecomment-1623416600)). 

This updates both pages & app router to restore smooth scroll functionality if the only the route hash changes.

Fixes #51721
Closes NEXT-1406
2023-07-20 06:13:04 +00:00
Zack Tanner
4994a428ae
improve error DX on pages with RSC build errors (#52843)
### What?
- Visiting a page in the app router without a proper component export doesn't show the dev overlay, but logs errors to the console
- When it does show the error overlay (e.g. during an HMR event), the error message was sharing the module code itself rather than the component path, making it hard to debug

### Why?
`createComponentTree` can throw these errors before the AppRouter tree is mounted, leaving the errors uncaught by the dev overlay.

### How?
This wraps the server root in the `ReactDevOverlay` when in dev mode with a minimal "HMR" for when the server component is edited (to reload the page).

Closes NEXT-308
2023-07-20 00:32:57 +00:00
Wyatt Johnson
3e821ef189
Support basePath with edge runtime for Custom App Routes (#52910)
Fixes a bug where the edge runtime didn't support `basePath` with Custom App Routes.

- Fixes #49661
2023-07-19 23:54:34 +00:00
Soheil Nazari
20b115e827
wrong content for next.config.mjs for MDX Plugins (#52738) 2023-07-19 21:55:40 +00:00
Darshan Jain
7771e78207
Fixed:#52853 Lacking 'color' attribute in IconDescriptor Metadata (#52902)
Fixes #52853

Lacking 'color' attribute in IconDescriptor  Metadata

```diff
export type IconDescriptor = {
  url: string | URL
  type?: string
  sizes?: string
+ color?: string          // added the color attribute 
  /** defaults to rel="icon" unless superseded by Icons map */
  rel?: string
  media?: string
  /**
   * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/fetchPriority
   */
  fetchPriority?: 'high' | 'low' | 'auto'
}
```


https://github.com/vercel/next.js/blob/v13.4.11-canary.0/packages/next/src/lib/metadata/types/metadata-types.ts#L99
2023-07-19 21:45:58 +00:00
Adam Hunter
2c1c8fa089
docs: fix example component in MDX documentation (#52753) 2023-07-19 14:25:31 -07:00
Steven
b12e6fef0c
chore(docs): fix typo in generate metadata docs (#52904)
- See current bug:
https://nextjs.org/docs/app/api-reference/functions/generate-metadata#generatemetadata-function
- Closes #52903
2023-07-19 14:21:18 -07:00
Antoine Bourin
08e87fb405
docs: add Typescript statically typed links mention in link doc (#52847) 2023-07-19 14:15:04 -07:00
Jiachi Liu
ec8af55833
Update vendor @vercel/og (#52897)
Upgrade `@vercel/og` to latest version

https://github.com/vercel/og/releases/tag/0.5.9
2023-07-19 21:04:27 +00:00
JJ Kasper
ec7f6f7f0c
Update runs-on tags 2023-07-19 13:20:44 -07:00
Tobias Koppers
446b172780
update turbopack (#52899)
* https://github.com/vercel/turbo/pull/5563
2023-07-19 18:17:57 +00:00
Tobias Koppers
86d7b85dc9
Turbopack: Next.rs API improvements (#52856)
### What?

* adds `Project.update` to update project options
* fix manifest paths to be under `server`
* pass `env` into project
* handle and expose issues in all methods
* expose server paths in WrittenEndpoint
2023-07-19 19:50:15 +02:00
Jiachi Liu
31453fa20e
Lock node version to 18.16 (#52894)
As we're using nodejs with latest version of 18.x on CI, there's a new behavior change of `url.fileURLToPath` that didn't join the paths as expected

locally with node 16.x or 18.16
```
/private/var/folders/mh/y8kwzkls6v3_w3_k6q384cw80000gn/T/next-install-b033b516612809c6fb0a0de77c6e50f7d7f8af34dfd3d01812b99345352dc992/node_modules/.pnpm/file+..+next-repo-7e52b07043e986127273a2d951e5c412b0dd45fb24eb34001bd372e2afff79db+packages+n_vyqu6i4c4i3efp5pqsaeaoe5s4/node_modules/next/dist/compiled/@vercel/og/noto-sans-v27-latin-regular.ttf
```

in the actions runner with node 18.17 it's
```
/tmp/next-install-8efaa47c1546bed07990d8f130decceb6536e1a36146e7885cb68e3c3dea21f7/node_modules/.pnpm/file+..+next-repo-9679355e05341947e7aa0b42c994e3ac_krcuriy4thl7zawouf7sswlrgy/node_modules/next/dist/compiled/@vercel/og/index.node.js/../noto-sans-v27-latin-regular.ttf
```

You can see that `index.node.js` is still present in the path as a folder which is unexpected
```
index.node.js/../
```

x-ref: https://github.com/vercel/next.js/actions/runs/5600417148/jobs/10242827739?pr=52790
2023-07-19 16:15:58 +00:00
Steven Tey
55fdfe4280
Update 02-edge-and-nodejs-runtimes.mdx (#52888)
Added clarification that runtime edge can be defined on Layout level too.

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
Co-authored-by: Balázs Orbán <18369201+balazsorban44@users.noreply.github.com>
2023-07-19 14:41:01 +00:00
Jimmy Lai
91c31c69b0 Revert "stuff"
This reverts commit 85bd7cc11f.
2023-07-19 14:00:54 +02:00
Jimmy Lai
85bd7cc11f stuff 2023-07-19 13:56:46 +02:00
Joseph Garrone
f5272acbe5
docs: Add tss-react for CSS-in-JS docs (#52764) 2023-07-18 19:48:01 -07:00
Rinald
d18334ae92
docs: Improve OpenTelemetry manual config (#52784) 2023-07-18 19:46:30 -07:00
Kévin Dunglas
d8660bb059
docker examples: improve perf by using COPY --link (#52835)
### What?

Uses `COPY --link` instructions in Docker examples.

### Why?

This significantly [accelerates Docker builds and improves caching](https://www.howtogeek.com/devops/how-to-accelerate-docker-builds-and-optimize-caching-with-copy-link/).

This instruction is supported for more than 1 year and is now supported by almost all modern Docker installations.
We use it successfully for a while in [the API Platform distribution](https://github.com/api-platform/api-platform/blob/main/pwa/Dockerfile), which includes Next.js and is derived from these examples.

### How?

By updating the existing examples.
2023-07-18 20:44:46 +00:00
Yagiz Nizipli
0f945637b9
perf: optimize flat-readdir to use fs.opendir (#52361)
This pull request replaces `readdir` with `opendir` and simplifies the
implementation.

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2023-07-18 22:16:26 +02:00
Tobias Koppers
0aeda3aedc
Turbopack: ensure output assets reference only output assets (#52832)
### What?

refactoring see https://github.com/vercel/turbo/pull/5557

### Turbopack Changes

* https://github.com/vercel/turbo/pull/5506 <!-- Leah -
feat(turbopack-ecmascript): implement acyclic SCC graph for ESM imports
-->
* https://github.com/vercel/turbo/pull/5557 <!-- Tobias Koppers - Ensure
output assets reference only output assets -->
2023-07-18 21:54:38 +02:00
Wyatt Johnson
87763d73e0
Rename Webpack Layers (#52605)
Renames the webpack layers to be more semantical:

```
server compiler:
server layer → RSC layer
client layer → SSR layer
shared layer → shared layer

client compiler:
appClient layer → app browser layer
```
2023-07-18 18:48:27 +00:00
JJ Kasper
fc86c4123b
Update labeler config (#52844) 2023-07-18 18:12:26 +00:00
Janicklas Ralph
009b6a19d6
Setting up third-parties package (#51194)
This PR Introduces `next/third-parties`

- `@next/third-parties` is a new package in the Next.js monorepo. 
- The package contains collection of components that can be used to
efficiently load third party libraries into your Next.js application.
- This package uses [Third Party
Capital](https://github.com/GoogleChromeLabs/third-party-capital/) under
the hood to fetch the best loading recommendations.
- This PR mainly sets up the package to run a script at build time to
auto generate the components from [Third Party
Capital](https://github.com/GoogleChromeLabs/third-party-capital/)
config.

Packages are grouped by company, for eg:

`import { GoogleMapsEmbed } from '@next/third-parties/google'`


cc: @housseindjirdeh @kara 
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------
2023-07-18 10:52:39 -07:00
OJ Kwon
2cea3f7000
feat(next-swc): support env var for --experimental-turbo (#52841)
### What?

Minor update to next-swc to support `__INTERNAL_CUSTOM_TURBOPACK_BINDINGS` for the --experimental-turbo entrypoint as same as current --turbo.
2023-07-18 17:45:02 +00:00
vercel-release-bot
5bf2bbb378 v13.4.11-canary.0 2023-07-18 17:12:06 +00:00
Facundo Giuliani
a26bac9604
Update default moduleResolution in tsconfig.json from node to bundler (#51957)
This updates our `moduleResolution` to `bundler` as this matches our heuristics much more closely so is more accurate. This shouldn't be a breaking change is it should be compatible with our previous default. 

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-07-18 15:11:09 +00:00
Tobias Koppers
3f1b9178cc
Turbopack: move references() to specific traits (#52822)
### What?

refactoring

see https://github.com/vercel/turbo/pull/5555

### Turbopack Changes

* https://github.com/vercel/turbo/pull/5544 <!-- Tobias Koppers - add
direct cycle detection -->
* https://github.com/vercel/turbo/pull/5547 <!-- Alex Kirszenberg - Add
missing feature to syn -->
* https://github.com/vercel/turbo/pull/5555 <!-- Tobias Koppers - move
references() to specific traits -->
2023-07-18 15:32:00 +02:00