Commit graph

8179 commits

Author SHA1 Message Date
Shu Ding
e42a3d6d48
Fix loader rule with wrong matching conditions (#47261
This Webpack loader rule should have the exactly same conditions as


828fd5a162/packages/next/src/build/webpack-config.ts (L1940-L1951)

Except that it matches 2 special layers and an extra loader.
2023-03-17 23:35:02 +01:00
Steven
5ed66e54d1
chore: add missing ts type in next-edge-app-route-loader (#47243)
Follow up to #47219
2023-03-17 22:33:10 +00:00
Steven
1aaae2998d
feat: add fetchPriority to next/image (#47222)
- Closes #43096 
- Available since Chrome 101:
https://chromestatus.com/feature/5273474901737472
- Coming to Safari: https://bugs.webkit.org/show_bug.cgi?id=252739
- Introduction blog: https://web.dev/priority-hints/


fix NEXT-319 ([link](https://linear.app/vercel/issue/NEXT-319))
2023-03-17 14:48:13 -07:00
JJ Kasper
ad223c816c
Ensure config and fetch revalidate are honored (#47255)
This ensures revalidate can be fetch specific instead of cache key
specific and adds a test case to ensure config based revalidate isn't
overridden by fetch based revalidate.
2023-03-17 14:00:07 -07:00
Jiachi Liu
e601a3b532
Support manifest.json static and dynamic route (#47240)
* Add `manifest.webmanifest` and `manifest.(j|t)xs?` support for
manifest.json route
* Add `Manifest` type for it for autocomplete purpose.

Remove the exports for `SitemapFile` and `RobotsFile` globally, will
discuss how to re-export them with better naming later

Small fix for `Robots` typing, should allow `string | string[]` for user
agent of single Robots

Closes NEXT-839

---------
2023-03-17 12:11:34 -07:00
Wyatt Johnson
e29bd49d87
i18n Improvements (#47174)
This serves to correct a specific issue related to multiple locales being specified in the pathname as well as some general i18n improvements.

- Multiple locales are now parsed correctly (only taking the first locale, treating the rest of the string as the pathname)
- `LocaleRouteNormalizer` has been split into `I18NProvider` and `LocaleRouteNormalizer` (tests added)
- Adjusted the `I18NProvider.analyze` method (previously `LocaleRouteNormalizer.match`) to require the `defaultLocale: string | undefined` to ensure consistent behaviour
- Added more comments around i18n
2023-03-17 18:48:09 +00:00
AdamKatzDev
9dbd8d7741
feat(standalone): allow configuring KEEP_ALIVE_TIMEOUT via env var (#46052)
Resolves #39689, partially resolves #28642 (see notes below)
Inspired by #44627

In #28642 it was also asked to expose `server.headersTimeout`, but it is
probably not needed for most use cases and not implemented even in `next
start`. It was needed to change this option before
https://github.com/nodejs/node/issues/27363.
There also exists a rare bug that is described here
https://github.com/nodejs/node/pull/32329#issuecomment-614119125. To fix
this exposing `server.headersTimeout` might be required both in
`server.js` and in `next start`.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-17 11:22:43 -07:00
Mrugesh Mohapatra
539cca853a
fix: typo in message for experimental.runtime (#47248)
<!-- 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 or adding/fixing 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 #

-->
Fixed a typo in the warning message for the experimental.runtime check
2023-03-17 11:07:10 -07:00
Shu Ding
8b44085b70
Fix CSS not being bundled in app dir (#45787)
Currently all import CSS resources, including CSS modules, are imported lazily. This means that they can't be chunked as by definition of "lazy" they can be loaded separately.

This PR changes it to always use "eager" so if they're in the same entry, these CSS resources can be chunked together and reduce the total amount of requests. However the downside will be tree shaking, as not all modules in a chunk are used by one entry. Two entries can only share a part of it.

Since CSS modules won't have side effects this should be a good trade off.

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

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

## Documentation / Examples

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


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-03-17 17:38:19 +00:00
Shu Ding
51b1fe3d2f
Emit late streaming meta tags (#47207)
Currently if `notFound()` or `redirect()` is called when the shell was already sent out, we can no longer change the status code and head tags. In that case we inject these specific meta tags into the HTML stream so specific agents can read them.

fix NEXT-220 ([link](https://linear.app/vercel/issue/NEXT-220))
2023-03-17 14:37:00 +00:00
Jiachi Liu
694e7f9e80
Generate metadata images generation with app routes (#47225)
Generated metadata icons through api routes instead of using webpack
emitting file. Each metadata image file will go through
`next-metadata-image-loader` to get the image basic info, and then it
will go through `next-metadata-route-loader` to be converted as a
routes.

Related to NEXT-264
Closes NEXT-810
2023-03-17 13:41:56 +01:00
Tim Neutkens
7a104a673b v13.2.5-canary.7 2023-03-17 13:31:21 +01:00
Gal Schlezinger
524bcd563b
[edge] support Node.js core modules in edge runtime (#47191)
This PR enables Node.js core modules in edge runtime by leaving a
`require` statement in the output source as externals

- [x] buffer
- [ ] async_hooks
- [ ] util 
- [ ] assert
- [ ] events
2023-03-17 13:29:31 +01:00
Tobias Koppers
d760c00961
print reason for compilation (#47190)
### What?

add reason of compilation to the `updated in` message.


![image](https://user-images.githubusercontent.com/1365881/225526729-7ada5e84-78a0-4518-ad9c-48178fd4e7cb.png)

### Why?

the general update in message is confusing and didn't show what is
happening.

Sometimes people are confused why turbopack compiles something. The new
messages explain that turbopack timings measure request handing duration
in addition to pure compilation time.

### How?

depends on https://github.com/vercel/turbo/pull/4208

fixes WEB-722
2023-03-17 13:22:25 +01:00
Tim Neutkens
6aa8c3768e v13.2.5-canary.6 2023-03-17 10:10:26 +01:00
Tobias Koppers
6eb33b7e68
update turbopack (#47205)
## Features

* https://github.com/vercel/turbo/pull/4208

## Testing

* https://github.com/vercel/turbo/pull/4211


Co-authored-by: Justin Ridgewell <112982+jridgewell@users.noreply.github.com>
2023-03-17 08:41:32 +00:00
Justin Ridgewell
875ddea183
next-swc: Switch to testing::fixture (#47183)
The old `test_generator::test_resources` could only find resources relative to the project root, and not relative to the test file. Because of the new nextpack directory structure, this causes all kinds of headaches between running in nextpack and running in turbo (`next.js/packages/next-swc` vs `nextpack/next.js/packages/next-swc`).
2023-03-17 06:18:25 +00:00
Shu Ding
922b5de06f
Support passing both closure arguments and parameters (#47212)
When calling the server (via `callServer`), we concat all closure values
(`$$bound`) and arguments of the function call into one array on the
client. Hence on the server, we will have to compile the function
differently to support that.

With this change, the compiled function will have a `$$with_bound` flag
to indicate that if it accepts closure values. If so, the only argument
passed will be an array like `[...bound_values, ...fn_args]`, and we
compile the function parameters to `(closure, arg1 = closure[N], arg2 =
closure[N + 1], ...)` where `N` is the number of the closure
identifiers. This way we can still fill these arguments by only pass an
"bound + args" array. If it doesn't accept closure values, it will be
directly called with `...fn_args` so no compilation change needed.

The reason that we use `arg1 = closure[N]` is that this can support
complex patterns in parameters such as `f(closure, {a} = closure[1], [b]
= closure[2])`.

fix NEXT-487 ([link](https://linear.app/vercel/issue/NEXT-487))
2023-03-16 19:11:13 -07:00
Shu Ding
45fe26f596
Fix missing option in createFromFetch (#47216)
This PR makes sure that `callServer` is specified in all Flight response creation calls. Added a test to cover HMR.

https://vercel.slack.com/archives/C03KAR5DCKC/p1678997184339409
2023-03-17 00:46:21 +00:00
Steven
bfed3985b1
fix: show error for api route handler with output: export (#47219)
In the case when the user configured `output: export` and used an API Route Handler that cannot be converted to static, Next.js must throw an error.

fix NEXT-823 ([link](https://linear.app/vercel/issue/NEXT-823))
2023-03-16 22:38:00 +00:00
Tim Neutkens
4e96e044d2 v13.2.5-canary.5 2023-03-16 21:53:59 +01:00
Tim Neutkens
cc0da4bd29
Opt-in to dynamic rendering when reading searchParams (#46205)
Ensures that using `searchParams` opts into dynamic rendering.

Fixes #43077 
fix NEXT-601 ([link](https://linear.app/vercel/issue/NEXT-601))

<!--
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:
-->

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

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

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2023-03-16 21:46:35 +01:00
Leah
dbdf47cf61
fix build issue and future incompatibility (#47176)
It was complaining about having 2 versions of sentry for some reason
2023-03-16 19:29:24 +00:00
Shu Uesugi
723626cf48
Handle defaultLocale on client router filter (#47180)
x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1678838567947919)

Follow-up to https://github.com/vercel/next.js/pull/46317. The issue is
that, if:

- `experimental.clientRouterFilter` is enabled
- `i18n` is enabled with `defaultLocale` set
- Next.js router navigates to a path that (1) is the same as
`defaultLocale` and (2) will be redirected,

then:

- **Expected:** Should hard-navigate to this path without any locale
prefix (and then redirect occurs)
- **Actual:** Hard-navigates to this path with `defaultLocale` prefix,
even though it's not needed (and then redirect occurrs)

### Solution

This PR fixes the above issue by adding `defaultLocale` to `addLocale`
which is passed to `handleHardNavigation`. [`addLocale` skips adding the
locale if `locale` is equal to
`defaultLocale`](02125cf3b1/packages/next/src/shared/lib/router/utils/add-locale.ts (L17)).

### Fixing a bug

- [x] Related issues linked using `fixes #number`
- [x] Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-16 11:58:02 -07:00
Jiachi Liu
1255e19965
Reorganize client references manifest (#46777)
* Rename client reference plugins from `Flight*` to `ClientReference*`
* Rename `serverComponentManifest` to `clientReferenceManifest`
* Group the key/value in client reference manifest
* Update turbopack crates
2023-03-16 18:10:32 +00:00
Jan Kaifer
53f29cd633
Add OTEL tests (#47149) 2023-03-16 16:35:07 +00:00
Will Binns-Smith
67aceea72b
Align on next-transform-font (#47179)
fix NEXT-827 ([link](https://linear.app/vercel/issue/NEXT-827))

This aligns use of the next/font transform across the workspace under a
single crate, now called `next-transform-font`.
2023-03-16 16:33:04 +01:00
Balázs Orbán
8c98a207f2
feat(cli): introduce --tailwind flag (#46927)
### What?

This PR introduces a new `--tailwind` flag to the `create-next-app` CLI,
to make it easier to bootstrap a Next.js app with Tailwind CSS
pre-configured. This is going to be the **default**. To opt-out of
Tailwind CSS, you can use the `--no-tailwind` flag.

### Why?

Tailwind CSS is one of the most popular styling solutions right now, and
we would like to make it easier to get started.

Currently, the closest you can come to this is by running `pnpm create
next-app -e with-tailwindcss` which will clone the
https://github.com/vercel/next.js/tree/canary/examples/with-tailwindcss
example. But that example is not configured for the App Router. This PR
will let you add Tailwind CSS to both `app/`, `pages/`, and start out
with TypeScript or JavaScript via the CLI prompts.

(Some community feedback
https://twitter.com/dev_jonaskaas/status/1632367991827443713,
https://twitter.com/samselikoff/status/1634662473331617794)

### How?

We are adding 4 new templates to the CLI bundle.

> Note: The styling is not pixel-perfect compared to the current
templates (using CSS modules) to require fewer overrides, but I tried to
match it as close as possible. Here are a few screenshots:

<details>
<summary><b>Current, light</b></summary>
<img
src="https://user-images.githubusercontent.com/18369201/224733372-9dba86fe-9191-471d-ad9f-ab904c47f544.png"/>
</details>

<details>
<summary><b>Tailwind (new), light</b></summary>
<img
src="https://user-images.githubusercontent.com/18369201/224733610-038d9d0f-634d-4b69-b5c2-a5056b56760c.png"/>
</details>

<details>
<summary><b>Current, dark, responsive</b></summary>
<img
src="https://user-images.githubusercontent.com/18369201/224733790-9b4d730c-0336-4dbe-bc10-1cae1d7fd145.png"/>
</details>

<details>
<summary><b>Tailwind (new), dark, responsive</b></summary>
<img
src="https://user-images.githubusercontent.com/18369201/224734375-28384bbc-2c3a-4125-8f29-c102f3b7aa1d.png"/>
</details>

#### For reviewers

This introduces 4 new templates, with a very similar code base to the
original ones. To keep the PR focused, I decided to copy over duplicate
code, but we could potentially create a shared folder for files that are
the same across templates to somewhat reduce the CLI size. Not sure if
it's worth it, let me know. Probably fine for now, but something to
consider if we are adding more permutations in the future.

---

~Work remaining:~

- [x] app+ts
	- [x] layout
	- [x] dark mode
	- [x] media queries
	- [x] animations
- [x] app+js
- [x] pages+ts
- [x] pages+js
- [x] prompt/config
- [x] deprecate Tailwind CSS example in favor of CLI
- [x] update docs
- [x] add test
- [x] add [Prettier
plugin](https://github.com/tailwindlabs/prettier-plugin-tailwindcss)
 
Closes NEXT-772
Related #45814, #44286
2023-03-16 16:06:27 +01:00
Tobias Koppers
588bf8ee20
improve turbopack error overlay (#47132)
### What?

Improve the UX of the error overlay

### Why?

* error overlay doesn't reopen when closed, but new error appear
* error overlay shows non-actionable warnings in node_modules
* error overlay shows unrelevant errors in node_modules

### How?

* low priority for errors in node_modules
* hide node_modules warnings
* open error overlay on new error
* Also updated the files I touched to the next.js prettier format


fixes WEB-712
fixes WEB-713
fixes WEB-714
fixes WEB-727

Co-authored-by: Leah <8845940+ForsakenHarmony@users.noreply.github.com>
2023-03-16 14:45:46 +00:00
Shu Ding
26a17fac6d
Adjust transpiler to support inlined server functions with annotations (#47186)
This PR makes sure that we are not appending statements after the function or arrow expression, if they're actions. Instead we put all them in a `ParenExpr` so the entire thing can be defined inline.
fix NEXT-813 ([link](https://linear.app/vercel/issue/NEXT-813))
2023-03-16 13:01:42 +00:00
Jiachi Liu
f36a6d8964
Not apply image loader to metadata images (#47197)
Previously when we move to metadata images to custom app routes, when the image files get imported, it matches the `next-image-loader` rule which accidentally generate a static file into media.

This PR appends the metadata reource query to the imported rerource, and then skip in the `next-metadata-route-loader` so they won't get applied by image loader or emit any unexpected assets
2023-03-16 11:51:18 +00:00
Tim Neutkens
341daf9c7d
Ensure router.refresh() matches revalidatePath('/') behavior (#46723)
Ensures `router.refresh()` matches the upcoming `revalidatePath('/')`
api. This also ensures that when server context has changed it applies
to all routes, not just the one that triggered the refresh.

- When `router.refresh()` is called we fetch the full RSC payload from
the server (root layout till the page)
- The client-side router cache is fully invalidated, effectively making
it empty
- The client-side router prefetch cache is fully invalidated,
effectively making it empty
- RSC payload is applied to the state


fix NEXT-590 ([link](https://linear.app/vercel/issue/NEXT-590))

<!--
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:
-->

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

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

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2023-03-16 10:14:21 +01:00
Ngô Đức Anh
a3dff7c8da
Fix(typedRoutes): fixed files from directories other than pages and app getting into Route (#47184)
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 or adding/fixing 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?

This PR fixes the issue where files from other directories are allowed into type `Route`.

### Why?

It is caused by the fact that `this.collectPage` only blocked files in `appDir` that are not `page.js` and `pages/`'s `_app.js`, `_document.js`,...

### How?

This fixes that by blocking files that are not in any of these directories as well.

Closes NEXT-
Fixes #47151
2023-03-16 00:58:33 +00:00
Steven
9a89c4933d
fix: app dir with next dev and output: export (#47171)
This PR is a follow up to PR #47022 which broke `next dev`.

A test has been added to confirm `next dev` works as expected.

fix NEXT-825 ([link](https://linear.app/vercel/issue/NEXT-825)) ([NEXT-825](https://linear.app/vercel/issue/NEXT-825))
2023-03-16 00:36:08 +00:00
Shu Ding
4c3f59f88d
Implement server entry creation in client layer (#47127
In short, this PR adds a 3rd layer to the server compiler. This extra
layer is for marking the modules when re-entering the server layer from
a client component. It is almost identical to the existing server layer
and it should have all the same bundling and runtime behaviors, but it's
still special because it's not allowed to enter the client layer again
from there.

Because of that, we create the extra entry for that new layer when the
client layer compilation finishes in the `finishModules` phase. The new
entry is handled normally as it's in the server layer. But the original
module in the client layer will be compiled specially as special no-op
exports, and will then be connected via the `callServer` wrapper.

fix NEXT-809 ([link](https://linear.app/vercel/issue/NEXT-809)).
2023-03-15 23:58:18 +01:00
Justin Ridgewell
02125cf3b1
Implement custom Turbopack Next transformers (#47137)
Builds on https://github.com/vercel/turbo/pull/4202 to implement custom Next.js Transformers in Turbopack.

This is the final piece to moving the `next-*` crates to Next. While we've _technically_ moved everything, Turbopack didn't support running custom transformers. So we're actually stuck on the last version we cut before deleting the next crates, running the transformers that exist in the turbopack repo. With the new support, we're almost back to the tip of main branch (there's still some snafu with `swc_core` upgrading that I'm working on).

Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
2023-03-15 19:10:59 +00:00
Shu Ding
4824d96fab
Fix RenderOpts type import (#47167)
Something missed in #47128.
2023-03-15 18:07:16 +00:00
Tim Neutkens
e6f33ec3a1 v13.2.5-canary.4 2023-03-15 11:55:55 +01:00
Shu Ding
6481c92038
Refactor app-render to decouple type definitions (#47128
This changes make sure that the `app-render` module isn't being imported
by too many unnecessary places, as we'll later move the renderer into a
worker.
2023-03-15 00:56:49 +01:00
Steven
b590ec3961
feat: add output: export support for appDir (#47022)
We can now support `next export` for `appDir` because of the new config added in #46744.
fixes NEXT-775 ([NEXT-775](https://linear.app/vercel/issue/NEXT-775))
2023-03-14 20:43:46 +00:00
Tobias Koppers
c27b546908
re-enable next-dev-tests (#47087)
### What?

enables the next-dev-tests crate integration tests from trubopack

### Why?

to unblock the move PR we temporarily disabled the tests

### How?

Fix the new location and fix the expect dependency

Fixes WEB-708

---------

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2023-03-14 16:05:19 +01:00
Tim Neutkens
e6bca73d87
Add support for scrolling to hash fragment (#46995)
Adds support for scrolling based on the [hash
fragment](https://en.wikipedia.org/wiki/URI_fragment) in client-side
navigations for the App Router, mirroring browser behavior.

- `#main-content` → scrolls to `id="main-content"` or
`name="main-content"` property
- `#top` → scrolls to the top of the page, this is a special case in
browsers.
- no hash → default scroll behavior, layout that changed

Fixes NEXT-658

<!-- 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 or adding/fixing 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 #

-->

fixes #44295

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-14 13:17:10 +01:00
JJ Kasper
6706a2a6ba
v13.2.5-canary.3 2023-03-13 21:46:07 -07:00
Talha Zekeriya Durmuş
16131e2d49
Fix #46621 - include status code in cache (#47096)
Fixes #46621

As explained here https://github.com/vercel/next.js/issues/46621,

> Using fetch to retrieve data inside a page on server side, the
response status code is incorrect when simply loading/reloading the
page. It looks like nextjs is caching the response without taking into
account the status code.

In following code we do not add status code information to the cache. 

https://github.com/vercel/next.js/blob/canary/packages/next/src/server/lib/patch-fetch.ts#L189-L206

However we are accessing this status code in 

https://github.com/vercel/next.js/blob/canary/packages/next/src/server/lib/patch-fetch.ts#L247-L250

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-13 21:37:22 -07:00
Sacha Stafyniak
c3ef208282
fix(mdx): export NextMDXOptions interface (#46441)
## Description

This allow to type mdx option externaly

```js
/** @type {import('@next/mdx').NextMDXOptions} */
export const options = {}
```

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

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

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2023-03-13 21:13:14 -07:00
Shu Ding
b4be6eb290
Continue page rendering after handling server requests (#47089)
This moves the position of action handling so it can continue page
rendering afterwards. And a `asNotFound` option is added to
`LayoutRouter` to indicate the router to opt into the root not-found
boundary, so not found pages can be programmatically rendered instead of
relying on route mismatching (this is also needed by NEXT-463 later).

Fixes NEXT-467.
2023-03-13 21:07:44 -07:00
Maia Teegarden
c3fa14d702
Correctly list unsupported turbopack experimental options (#47093)
* Fixes an issue where unsupported experimental options were not listed
correctly
* Fixes formatting if more than one unsupported option is configured
* Shows unsupported options first and makes it slightly more clear blue
options are supported

Before:

![Screenshot 2023-03-13 at 2 23 53
PM](https://user-images.githubusercontent.com/2865858/224835658-127b3a75-527b-4014-9622-b667c927544a.png)

After:

![Screenshot 2023-03-13 at 2 33 11
PM](https://user-images.githubusercontent.com/2865858/224837224-2d0ada71-4440-496f-b99a-a776835ce1f6.png)

---------
2023-03-13 18:22:19 -07:00
Jiachi Liu
bfd6c3ea2e
Dynamic routes for toplevel robots and sitemap (#47091)
Support top-level `robots.[ext]` and `sitemap.[ext]` with dynamic api
routes

* Use isAppRoute to determine api routes and metadata routes as metadata
routes are normalized as `<metadata>/route`
* Normalize path to auto append extension to pathname for sitemap.js and
robots.js
* Add typings `SitemapFile` and `RobotsFile`
* move the normalize logic together, reuse the `absolutePathToPage`.
Changes less when touching both dev-server/hot-reloader and next-server,
use the same utils to handle paths

Closes NEXT-262

---------
2023-03-13 18:04:31 -07:00
Ngô Đức Anh
1c83bb868d
Fix(typedRoutes): fixed empty DynamicRoutes or StaticRoutes causing Route to turn into type string (#46980)
Fixes #46974

When `dynamicRouteTypes` or `staticRouteTypes` is empty, type `DynamicRoutes`/`StaticRoutes` fallbacks to type `string`, causing type `Route` to resolve to type `string` as well, meaning that the user can use any string as `href`. This fixes that by making those types fallback to type `never` instead, and if both `dynamicRouteTypes` and `staticRouteTypes` are empty, fallback to type `string`.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

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

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2023-03-14 00:54:59 +00:00
Shu Ding
cbc511ba36
Verify router state query params can't grow out of control (#47094)
Not certainly sure about the reasonable limitation of this header. For example https://app-dir.vercel.app/context/books sends a state query of size ~110, consider an app with 100x more complicated nested, parallel and named segments, we still have a 3x extra room which should be enough.

Fixes NEXT-137.
2023-03-13 23:37:11 +00:00
Hannes Bornö
cb729c1087
Remove experimental fontLoaders option from next.config.js (#46886)
Currently there's an experimental option in `next.config.js` that lets you define default subset(s) to preload for all your fonts. [docs](https://nextjs.org/docs/basic-features/font-optimization#specifying-a-subset)

Over time we haven't seen much use of this option, and we are defining the subsets in the font function call in all our examples/docs. Imo it would be fine to drop this option.

This PR removes that experimental option. If you happen to use it you'll get a build error with [a link](f67af163cd/errors/google-fonts-missing-subsets.md).

Next step (breaking change for next major) would probably be to remove the preload and subsets properties from `next/font/google` calls, and just have something like [`preloadSubsets´](https://vercel.slack.com/archives/C8EAN8A94/p1674868993169559?thread_ts=1674707555.461809&cid=C8EAN8A94) that is required.
2023-03-13 21:34:43 +00:00
Steamed_EGG
d08caa88ba
Fix: Update README templates in create-next-app (#47037)
To make them up to date with other templates

<!-- 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 or adding/fixing 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?



### How?

Closes NEXT-
Fixes #

-->
### Why?

I was using `create-next-app` to create my new app using the new `app`
directory but found out that `README.md` is outdated:
It shows informations for API Routes, which removed in #45819 in favor
of route handlers.

---------
2023-03-13 13:20:39 -07:00
Shu Ding
9b40be8e44
Implement route announcer for app dir (#47018)
This PR implements the route announcer for app directory. It almost uses
the same logic as the route announcer inside pages, with one notable
difference that the inner content node is now inside a shadow root. This
makes sure that it does as little impact as possible, to the
application. This is important as we no longer have the `__next`
wrapper.

Another thing worth mentioning is that the announced title is a global
singleton of the website. It shouldn't be affected by the concept of
layouts, but should be triggered when the router state (not just URL)
changes.

Closes NEXT-208.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-13 13:09:22 -07:00
Shu Ding
b21c85bcea
Detect common invalid cases for the server directive (#47069)
It will be crucial to detect these common problems and abort compilation, because it's intended to be using a server boundary but these problems might cause it ending up in the client.

Fixes NEXT-762.
2023-03-13 19:20:10 +00:00
JJ Kasper
0b3e357808
v13.2.5-canary.2 2023-03-13 11:46:11 -07:00
JJ Kasper
76f7645ce6
Update app route handler proxy handling (#47088)
This ensures our Proxy wrapping request fields works properly in the
edge-runtime by explicitly binding to the correct request instance.

x-ref: [slack
thread](https://vercel.slack.com/archives/C03UR7US95F/p1678730563467089?thread_ts=1678662292.695769&cid=C03UR7US95F)
2023-03-13 11:34:22 -07:00
Shu Ding
b146da6037
Refactor renderers and RenderResult (#46955)
This PR does two major changes:

1. Make sure both pages renderer and app renderer return `RenderResult`,
no more `null`. This was achieved with a new `null` type in the
constructor `new RenderResult(null)`, and a `.isNull()` method.
2. Remove all mutations of the `renderOpts` object inside renderers. To
pass extra information out, they need to be attached to the
`RenderResult` now. This also requires 1) to be done.

These changes are the initial steps to the isolated rendering worker
architecture. Besides those there're also some type improvements.

Fixes NEXT-807.

---------
2023-03-13 10:53:43 -07:00
Johannes Obermair
82ed6a3b0d
Fix next/image config injection during static generation (#47007)
Fixes #39330.

I've not added a new test, but extended the existing test instead (and
re-enabled it).

It seems to me that a custom next/image config was not considered during
static generation (which itself uses `next export`?) before. Adding the
config to `renderOpts` in `packages/next/src/export/index.ts` resolves
the issue.
2023-03-13 10:47:05 -07:00
Benjie
48b9c1a23c
Prevent handleDisconnect being called twice (#46959)
### Fixing a bug

When a timeout occurs the `handleDisconnect` can be called twice on my
machine (Chrome 110.0.5481.178). Once by the timeout code, and once by
the `onerror` handler, possibly triggered by the `source.close()` call.
This leads to every timeout triggering twice as many clients, which
quickly explodes to websocket reconnections spamming the network tab of
devtools. This trivial fix resolves the issue.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-13 10:34:45 -07:00
Justin Ridgewell
8ae2df0f10 Integrate next-* crates from Turbopack (#47019)
Update workspace cargo deps
Update cargo deps to point to local workspace
Ignore too-many-arguments warnings
Fix clippy errors
Update pnpm workspaces
exclude integration tests from unit tests CI
rust-analyzer settings
add rust flags and env vars
2023-03-13 14:33:17 +01:00
Tobias Koppers
b98469c86b Merge df38582da of vercel/turbo into canary 2023-03-13 14:23:56 +01:00
Shu Ding
baa22255da
Initial support of redirection in server handlers (#46944
This is an initial implementation of POST-driven redirection handling:
https://vercel.slack.com/archives/C035J346QQL/p1678321389089839. Highly
experimental.

Fixes NEXT-803, fixes NEXT-804.
2023-03-13 14:20:27 +01:00
LongYinan
cbd3c2983a
Cleanup remove directive logic to reduce allocate (#47055)
Reduce `unwrap` and `clone` usages
2023-03-13 10:25:04 +00:00
Shu Ding
25aa8693ad
Rewrite action transform in SWC (#47049)
This is almost a rewrite of the transform to simply some logic. For a `"use server"` file we now simply annotate every exported identifier and will later do runtime checks. This is because that we can't statically know the source of exported values.

This rewrite also makes it possible to annotate anonymous arrow functions.

Thanks to @kdy1 for some of the suggestions here.

Closes NEXT-708, closes NEXT-421.
2023-03-13 06:59:21 +00:00
JJ Kasper
acb174455f
Fix generateStaticParams check in app dir (#47051)
This ensures our `params` checking works properly with `app` dir. 

x-ref: [slack thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1678659475821299)
2023-03-13 00:05:35 +00:00
Tim Neutkens
287ad83399 v13.2.5-canary.1 2023-03-11 20:41:30 +01:00
Jiachi Liu
fdfd9beb5f
Add /route subpath to metadata static routes (#47030)
Set the output bundle file path to `/<metadata route>/route.js` to align with other custom app routes, in order to make it easier being handled by app routes in both nextjs and vercel
2023-03-11 19:22:01 +00:00
Yangshun Tay
c110dfd57c
fix: exclude 'mdx-bundler' from being bundled in server components (#46992)
`mdx-bundler` is used for server-side transformation of MDX files and currently using it within server components will throw a `Module parse failed: Unexpected token` error.

Adding `serverComponentsExternalPackages: ['mdx-bundler']` to `next.config.js` fixes the issue, but it's probably good to add to the default exclusion list as `mdx-bundler` is a relatively popular approach for using MDX in Next.js apps.
2023-03-11 02:12:10 +00:00
Maksym Anisimov
74891fde18
Add auto-detection of image/x-icon content type (#47013)
Added auto-detection of image/x-icon content type by analyzing response buffer

fixes https://github.com/vercel/next.js/discussions/45998

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-03-10 20:36:33 +00:00
Tobias Koppers
2e51690143 avoid sending modules in parent for dynamic imports (vercel/turbo#4056)
### Description

Keeps track of available modules when importing new chunk groups. Omits
assets that are already available in the parent chunk group(s) when
determining assets to be included in chunks.

### Testing Instructions

Dynamic imports should not include modules that are already in the
parent chunks

<!--
  When the below is checked (default) our PR bot will automatically
  assign labels to your PR based on the content to help the team
  organize and review it faster.
-->

- [x] Auto label
fixes WEB-599
2023-03-10 19:42:22 +00:00
Jesse Koldewijn
84104af63e
fix: added jsdom & canvas to the external packages list - fixes #46893 (#46990)
fixes #46893

### What?
fixing compile issue reguarding the dompurify package.

### Why?
To allow the usage of dompurify

### How?
Added jsdom and canvas to the external packages list which are used by dompurify and throw errors if not added to this list.
2023-03-10 19:27:41 +00:00
Hannes Bornö
c75c4e56c5
Update next/font/google data (#46988)
Add the new fonts to `next/font/google`.
2023-03-10 18:27:58 +00:00
OJ Kwon
4bea437c7d feat(ecmascript): transform ts input with runtime flags (vercel/turbo#4142)
### Description

Another attempt to close WEB-659.

The crux is same as previous PR, but attempt to change the location
where it read config / bubble down the config values to the actual
transform stage. Mainly, `enable_typescript_transform` is now accepting
an option instead of boolean flag to down to
`EcmaInputTransform::Typescript`, and `get_*_module_context()` reads the
config value as needed.
2023-03-10 18:23:29 +00:00
Tim Neutkens
7d48edfe8e v13.2.5-canary.0 2023-03-10 18:06:16 +01:00
Tobias Koppers
7e5881b72a
update turbopack (#46994)
# Bugfixes

* https://github.com/vercel/turbo/pull/4149
* https://github.com/vercel/turbo/pull/4151

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-10 17:59:48 +01:00
Jiachi Liu
fd6b93d46e
Generate fixed route path for favicon.ico (#46997)
Generate `/favicon.ico` route when favicon.ico is placed into `app/`.

Still collect favicon metadata image information through
metadata-image-loader but don't emit the file to static dist anymore.
Also collect favicon through metadata routes, and render it as static
routes. Also remove the `hash` we generated before, not needed anymore.

Change metadata static routes rendering process: collect static metadata
assets, read the buffer of the file data and return it in the response.

Closes NEXT-791
2023-03-10 17:12:44 +01:00
Shu Ding
d200e5fa1d
Support default arrow function export in server boundary (#46977
This PR adds basic support for default export of an async arrow
function:

```js
export default async (a, b) => { console.log(a, b) }
```

In upcoming PRs I'll refactor named export handling and inlined
declarations.
2023-03-10 14:38:51 +01:00
Shu Ding
10f2268f4e
Add Zod and router state validation (#46962)
This PR adds Zod to the precompiled libraries, and use it to create schemas for the router state tree for validation. In other planned features/changes, Zod will also be used to do run-time data validation.

Fixes NEXT-135.
2023-03-10 13:37:45 +00:00
Tobias Koppers
01f2524392 fix pathname for data requests (vercel/turbo#4149)
### Description

| input file         | HTML pathname | Data pathname    |
| ------------------ | ------------- | ---------------- |
| index.tsx          | /             | .../index.json   |
| blog.tsx           | /blog         | .../blog.json    |
| pricing/index.tsx  | /pricing      | .../pricing.json |
2023-03-10 08:40:43 +00:00
JJ Kasper
05f6de1086
v13.2.4 2023-03-09 16:41:28 -08:00
JJ Kasper
1ce3b36179
v13.2.4-canary.9 2023-03-09 14:46:45 -08:00
Noemi
71dbcacf17
Do not re-assign process.env (#46914)
## Checklist

- [ ] Related issues linked using `fixes #number` 
  - no related issue exists, happy to open one if desired
- [x] Tests added
- not sure if specific tests are needed? there is an integration test
for environment variables, and Next.js relies a lot on passing
information through environment variables; i'd expect everything to
break if this change broke environment variable handling
- [x] Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md
  - no new errors, does not apply

### What?

Re-assigning `process.env` substitutes the "magic object" that sets
environment variables at the process level with an ordinary JavaScript
object. This causes environment variables that are set after
`process.env` is re-assigned to not be visible to native add-ons.

See [this Node.js issue][issue] and [this reproduction case][repro] for
details.

[issue]: https://github.com/nodejs/node/issues/46996
[repro]: https://github.com/unflxw/nodejs-process-env-addons-repro

### Why?

In general, paraphrasing the maintainer in the Node.js issue,
re-assigning `process.env` is not a thing you should do. More
specifically, I'm trying to use Next.js' experimental OpenTelemetry
support with AppSignal's Node.js integration, which also uses
OpenTelemetry.

The AppSignal Node.js package sets environment variables in order to
configure a long-running process, which is then launched through a
native add-on. Because of the re-assignment of `process.env` that occurs
early in Next.js' lifecycle process, by the time the AppSignal Node.js
package sets environment variables, it's setting them in an ordinary
JavaScript object that Next.js left in the global `process` object, not
in the magic one created by the Node.js runtime.

This means that these environment variables are not _actually_ being set
for the process at the OS level, and therefore they're also not set for
the native add-on, or for the long-running process it spawns.

### How?

A `replaceProcessEnv` function is implemented that takes an environment
object as an argument, and applies the difference between that
environment object and the current environment to the existing
`process.env` object. This function is used instead of re-assigning
`process.env`.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-09 14:41:50 -08:00
Seiry Yu
9f08ef8daf
fix: Add NODE_OPTIONS for debugging in next-dev (#46757)
<!--
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:
-->

## Bug
fix #46948 
- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

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

## Documentation / Examples

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

Co-authored-by: Seiry Yu <seiry@squareup.com>
2023-03-09 14:12:54 -08:00
Justin Ridgewell
8e14b672cc
Update Turbopack to 230309.2 (#46971)
# New Features
- https://github.com/vercel/turbo/pull/3975

# Bug Fixes
- https://github.com/vercel/turbo/pull/4129
- https://github.com/vercel/turbo/pull/4134
- https://github.com/vercel/turbo/pull/4062

# Performance
- https://github.com/vercel/turbo/pull/4093
2023-03-09 13:24:24 -08:00
Hannes Bornö
9a41ba9ac4
Improve RSC compiler error in external module (#46953)
When the RSC compiler error was caused by an external package, make the
error message display which import caused the error. Also don't show
node_module files in the import trace.

Continuation of https://github.com/vercel/next.js/pull/45484

Before

![image](https://user-images.githubusercontent.com/25056922/224032476-6811a1d5-d690-48be-9602-781f459edc70.png)

After

![image](https://user-images.githubusercontent.com/25056922/224032177-2d0b2977-098f-46bd-8e30-9e6bc21b9153.png)

Updates the format of the files, from `app/page.js` to `./app/page.js`
to align it with other import traces.

![image](https://user-images.githubusercontent.com/25056922/224030420-1d3ff0ba-5747-4ed3-8b0b-9c4deace54ea.png)


Closes NEXT-523
2023-03-09 12:27:57 -08:00
Jiachi Liu
1e7f4a58fe
Update vendored react (#46970)
Update to latest next channel of react

mainly for https://github.com/facebook/react/pull/26353

```
-  3706edb81 [Float][Fizz]: Don't preload nomodule scripts (#26353) (Josh Story)
-  2b003a5cc Split out ServerReferenceMetadata into Id and Bound Arguments (#26351) (Sebastian Markbåge)
-  62cd5af08 Codemod redundant async act scopes (#26350) (Andrew Clark)
-  037378202 Internal `act`: Call scope function after an async gap (#26347) (Andrew Clark)
-  d8e49f2af Use setTimeout to schedule work on the server in Edge environments (#26348) (Sebastian Markbåge)
-  83643778b Internal test helpers: Use Node's MessageChannel to queue task (#26345) (Andrew Clark)
-  f36ab0e37 Remove timers from ReactDOMSuspensePlaceholder tests (#26346) (Andrew Clark)
-  44d380794 Move internalAct to internal-test-utils package (#26344) (Andrew Clark)
-  8c100620c Build: specify Node.js 16 as minimum for dev (#26343) (Jan Kassens)
-  d81447304 [Internal API only] Delete non-awaited form of act (#26339) (Andrew Clark)
-  702fc984e Codemod act -> await act (4/?) (#26338) (Andrew Clark)
-  9fb2469a6 Restore definition of NativeMethods as an object for React Native (#26341) (Rubén Norte)
-  aef930314 [DevTools] upgrade electron to latest version & security improvements (#26337) (Mengdi Chen)
-  161f6ae42 Codemod act -> await act (3/?) (#26336) (Andrew Clark)
-  58605f798 Codemod act -> await act (2/?) (#26335) (Andrew Clark)
```
2023-03-09 11:44:33 -08:00
Jiachi Liu
36ca1598d5
Support static file robots.txt and sitemap.xml as metadata route (#46963)
Support top level static `robots.txt` and `sitemap.xml` as metadata
route in app directory. When those files are placed in top root
directory

Refactored a bit the page files matching logic, to reuse it between dev
server and build

Closes NEXT-267
2023-03-09 11:10:18 -08:00
Tobias Koppers
511b244f4a improve introspection (vercel/turbo#4135)
### Description

Add more details to introspection and make it more robust to errors
during introspection

### Testing Instructions

go to http://localhost:3000/__turbopack__/
2023-03-09 16:08:03 +00:00
Tobias Koppers
42fa76a3f7 fix app dir with latest next.js (vercel/turbo#4134)
### Description

* [fix manifest for
__ssr_module_mapping__](4abd87312d)
* [add missing styled-jsx
alias](d9b4a4df7f)

### Testing Instructions

layout-playground
2023-03-09 16:05:29 +00:00
Alex Kirszenberg
2ffcc59ea7 Merge EcmascriptChunkUpdates before sending them to the client (vercel/turbo#3975)
This diff:
* introduces the `VersionedContentMerger` trait, which allows for
merging the updates of versioned contents within the same chunk group;
* implements this for `EcmascriptChunkContent`/`EcmascriptChunkUpdate`,
turning them into
`EcmascriptMergedChunkContent`/`EcmascriptMergedChunkUpdate`;
* creates a new `ChunkList` asset which is capable of merging chunk
updates of chunks within the same chunk group, and create such an asset
for dynamic chunks (through manifest/loader_item.rs) and chunk group
files assets.

This fixes a bunch of edge cases related to HMR:
* HMR of dynamic imports now works;
* Chunks getting added/deleted/renamed now also works with HMR, since
we're listening to updates at the chunk group level;
* CSS chunks get reloaded in the right order, with respect for
precedence.

There are still known edge cases with HMR:
* CSS chunks added through HMR are not inserted at the right position to
respect precedence (WEB-652).
* Update aggregation is disabled because we don't want a critical issue
to stop all HMR (WEB-582) . This would be fixed by applying aggregated
updates when dismissing the error modal, but there are some edge cases
with this too (e.g. what happens when an HMR update also causes an error
on top of an existing error).
2023-03-09 11:13:04 +00:00
JJ Kasper
715f96fb49
v13.2.4-canary.8 2023-03-08 16:06:57 -08:00
Shu Ding
ddff41a908
Support re-exporting unnamed function expression (#46936)
Add support for cases like:

```js
const foo = async function () {}
export default foo

const bar = async function() {}
export { bar }
```

Also fix a bug where nested async function declarations are mistakenly
counted as actions.

Fixes NEXT-800.
2023-03-08 15:07:31 -08:00
Tobias Koppers
e6103ae6dd update next.js version (vercel/turbo#4130) 2023-03-08 22:34:04 +00:00
JJ Kasper
80f2293a01
Revalidate generateStaticParams/Paths in background in dev (#46940)
Follow-up to https://github.com/vercel/next.js/pull/46906 this ensures
we revalidate `generateStaticParams`/`getStaticPaths` in the background
in development so that we aren't blocking refreshes an much
un-necessarily if the paths cache is already populated.

Fixes: https://github.com/vercel/next.js/issues/44646
Fixes: https://github.com/vercel/next.js/issues/38757
x-ref:
https://github.com/vercel/next.js/discussions/17977#discussioncomment-142104
x-ref: https://github.com/vercel/next.js/discussions/20076
x-ref: https://github.com/vercel/next.js/discussions/14378
2023-03-08 14:33:28 -08:00
Hannes Bornö
de6a1e3d76
Rename FontLoaderManifest to NextFontManifest and add better comments (#46922)
Rename FontLoaderManifest to NextFontManifest to make it more obvious
that it has to do with `next/font`.

There's a change to how the plugin determines if a module is generated
by `next/font`. Instead of looking at the target CSS file
https://github.com/vercel/next.js/blob/v13.2.4-canary.6/packages/next/src/build/webpack/plugins/font-loader-manifest-plugin.ts#L37-L49.
It simply looks if the module has `next-font-loader` in its loaders:
https://github.com/vercel/next.js/compare/canary...hanneslund:next.js:next-font-build-cleanup?expand=1#diff-34d7972c68687e875c868847f782f369c3af162a9af10949f3577660775afcb2R65-R74

Also more comments added to the manifest plugin and the `next/font`
postcss plugin.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-08 13:58:57 -08:00
Shu Ding
bae5d6fcd4
Validate the router state header on the server (#46925)
Ensure that the router tree state header is one single, valid value.

Fixes NEXT-136.
2023-03-08 13:44:17 -08:00
Shu Ding
b3220fe322
Validate req.url in renderer (#46923)
It's possible that the request is missing or having an invalid URL, and
got passed to the renderer.

Fixes NEXT-139.
2023-03-08 13:16:42 -08:00
Hannes Bornö
02eb34db01
Use https_proxy environment variable in next/font/google (#46822)
When fetching CSS or font files from Google Fonts, it won't work if
you're required to use a proxy. This change makes it look for the
`http(s)_proxy` environment variable, and if it's defined it creates a
fetch agent using
[https-proxy-agent](https://github.com/TooTallNate/node-https-proxy-agent).

Also fixes fetch errors not being properly logged.

Fixes #45034
Closes NEXT-690

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

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

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2023-03-08 12:23:32 -08:00
JJ Kasper
f99ae5af97
v13.2.4-canary.7 2023-03-08 11:52:58 -08:00
Justin Ridgewell
612d578188
Update Turbopack to 230308.3 (#46935)
# Bug Fixes
- https://github.com/vercel/turbo/pull/4121
- https://github.com/vercel/turbo/pull/4111
2023-03-08 11:25:23 -08:00