Commit graph

9365 commits

Author SHA1 Message Date
Kyle Satti
d0cbf359dd
Updates @typescript-eslint/parser to 6.1.0 (#52848)
### What?
Updates the `@typescript-eslint/parser` dependency of `eslint-config-next` to the latest release `6.1.0`. 

### Why?
This is blocking NextJS developers from updating their own dependency on `@typescript-eslint/eslint-plugin`, which in turn requires `@typescript-eslint/parser@6.1.0`

### How?
Updated the package.json and ran `pnpm install`. I'm assuming that CI will catch any issues with the update (I know this could be deemed as a bit lazy, so apologies for that. It's all I have time to do at the moment).
2023-07-25 22:29:03 +00:00
vercel-release-bot
f89987f09d v13.4.13-canary.2 2023-07-25 19:56:56 +00:00
JJ Kasper
e60a1e747c
Fix minimal basePath handling (#53174)
We no longer handle basePath stripping further down in minimal mode so
this prevents the re-adding we used to do.

Manually tested with
https://33-base-path-gsp-404-m8w6hhs1m-vtest314-ijjk-testing.vercel.app/docs/api/hello

Fixes: [slack
thread](https://vercel.slack.com/archives/C03F2CMNGKG/p1690309135573409)
2023-07-25 12:33:43 -07:00
vercel-release-bot
87acd0432a v13.4.13-canary.1 2023-07-25 14:48:22 +00:00
Steven
32278603fd
chore: extract common get-validated-args (#53165)
- Closes #53044 

Co-authored-by: ZYSzys <23313266+ZYSzys@users.noreply.github.com>
2023-07-25 14:25:52 +00:00
Balázs Orbán
e1133cf097
fix(edge): allow Request cloning via NextRequest (#53157)
### What?

Allow the following:

```ts
new NextRequest(new Request(...))
```

### Why?

Cloning a request by passing it to the constructor of another `Request` is allowed by the spec: https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#parameters

### How?

If the passed argument is an instance of `Request`, we pass it as-is to `super()`

Fixes #52967
Closes NEXT-1468
2023-07-25 11:36:39 +00:00
vercel-release-bot
d680975537 v13.4.13-canary.0 2023-07-24 23:10:37 +00:00
Steven
a0856eb596
chore: update warning message from yarn add sharp to npm i sharp (#53130)
Previously, this warning message assumed the user knew what `yarn` was and had it installed.

This PR changes the warning message to assume the user knows what `npm` is and has it installed, since `npm` ships with the official `node` installation.
2023-07-24 22:33:12 +00:00
Jiachi Liu
d8f4fa8946
Fix not found hangs the build with overridden node env (#53106)
### Why

In #52985 the not found solution introduces `NODE_ENV` to determine if it his the not found boundary and should render the not found, as in the next build mode, we have `/_not-found` as a special route which has a empty parallel route, but in next dev mode so far it his the `parallel-default-route`. This could dependend on the `NODE_ENV` passing to next server but not necessarily.

### What

Fixes #53082
Fixes #53083 

### How

When server actions `not-found` hits, now we create a new loader tree based on the previous one, including `layout` and other components but not the children parallel routes

For production case, to make the rendering independent from the `NODE_ENV`, we're using original pathname to check if it's `/_not-found` to determine if it's production build 404 page

To support replace the loader tree of action, did a little refactor that passing down the loader tree from top level to `bodyResult`. Then we can change the loader tree itself before rendering, in short, we tweak it from original tree to one for not-found case, so server actions could render it properly
2023-07-24 21:00:53 +00:00
OJ Kwon
9da305fe32
feat(turbopack): emit MODULE_FEATURE telemetry from turbopack (#52356)
### What?

closes WEB-1274. In effort to create feature parity to existing webpack/telemetry-plugin, this PR attempts to define a new struct `ModuleFeatureTelemetry` and emit it via resolve plugin, if module & its subpath matches to the existing plugin.

next-dev (--experimental-turbo) now will emit telemetry payload with other output, however this PR does not actually `record` telemetry via `telemetry.record` since original webpack telemetry records it in prod build only.
2023-07-24 20:07:32 +00:00
Tobias Koppers
4558fac29b
move webpack specific logic into a separate file (#53114)
### What?

move webpack specific code out of the `client/index.ts` file

### Why?

sharing with turbopack. Avoiding extra shims to fake webpack.
2023-07-24 19:07:58 +00:00
Sukka
d8c4700a37
refactor(codemod): replace chalk with picocolors (#53115)
The PR replaces `chalk` inside `@next/codemod` with `picocolors`.

Generally, `@next/codemod` is used through `npx`/`pnpx` as it serves as a sort of "one-time fix". By replacing `chalk` with the `picocolors` (which is 14 times smaller and 2 times faster), we can speed up the installation process of `npx @next/codemod`.

Currently, `@next/codemod` has about 10k downloads per week, so I guess this PR is worth it:

<img width="441" alt="image" src="https://github.com/vercel/next.js/assets/40715044/a32fd6e0-bbe6-48e8-985d-83393c141b23">

In my next PR, I will replace `chalk` inside `create-next-app` with `picocolors` as well.
2023-07-24 17:56:45 +00:00
Tobias Koppers
909dad557d
Turbopack: use edge environment in server-side rendering of client components too (#53099)
### What?

* use the correct edge resolve options for SSR of client components

### Why?

It need to use the edge import conditions here for
https://github.com/vercel/next.js/pull/51083
2023-07-24 19:24:30 +02:00
Alex Kirszenberg
2cd0c8abc7
Add app, error, and document entrypoints (#53013)
### What

adds endpoints for `_app` `_error` and `_document` for pages

Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
2023-07-24 08:57:48 +00:00
Tobias Koppers
c8eb7f3de0
update Turbopack (#53098)
* https://github.com/vercel/turbo/pull/5574
2023-07-24 07:18:27 +00:00
akfm
1494283a74
fix: Add Next-Url to http vary in consideration of intercept routes. (#52746)
### Why

We calculate the “next url” depending on the router state and the previous router state so that when you navigate to a route, the proxy matches with that header and returns you the intercepted route if matching

### What 
- Fixes #52745




Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
2023-07-22 21:38:23 +00:00
Shu Ding
7843204938
Improve internal web stream utils (#53004)
This PR refactors some code specifically related to web stream utilities. Please read the review comments for more details.
2023-07-22 14:49:58 +00:00
JJ Kasper
1398de9977
Revert "Revert "Separate routing code from render servers (#52492)"" (#53029)
Reverts vercel/next.js#53016
2023-07-21 14:02:52 -07:00
vercel-release-bot
552bca46eb v13.4.12 2023-07-21 20:30:24 +00:00
vercel-release-bot
576cb6ed4f v13.4.12-canary.0 2023-07-21 19:40:40 +00:00
JJ Kasper
ac62406ca0
Revert "Separate routing code from render servers (#52492)" (#53016)
Temporarily reverts these changes to allow patch release first. 

Reverts: https://github.com/vercel/next.js/pull/52149
Reverts: https://github.com/vercel/next.js/pull/52492
2023-07-21 10:52:19 -07:00
Jiachi Liu
1fefb4a8d2
Reland "Refine the not-found rendering process for app router" (#52985)
Reland #52790
Reverts vercel/next.js#52977

was failed due to failed job
[vercel/next.js/actions/runs/5616458194/job/15220295829](https://github.com/vercel/next.js/actions/runs/5616458194/job/15220295829)

Should be fine to resolve with
https://github.com/vercel/next.js/pull/52979 now

Fixes #52718
Fixes #52739

---------

Co-authored-by: Alex Kirszenberg <alex.kirszenberg@vercel.com>
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2023-07-21 10:09:30 -07: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
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
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
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
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
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
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
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
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
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