Commit graph

15802 commits

Author SHA1 Message Date
Sophie Alpert
05cd5157e5
app router: Fix infinite redirect loop in MPA navigation (#49058)
Not 100% convinced that this is the correct fix but it's the best I can
think of.

Previously, we would sometimes call location.assign()/.replace()
hundreds of times (or more) as I described in
https://github.com/vercel/next.js/issues/48438 and
https://github.com/vercel/next.js/issues/48309#issuecomment-1512290958.
Sometimes this would just make things slow but the navigation would
eventually succeed; sometimes this would just hang the browser.

Now we trigger it only once (or—for a reason I don't quite
understand—twice in dev, as you can see in the test) and never commit
that render.

This also fixes the bug I mentioned in
https://github.com/vercel/next.js/issues/48438#issuecomment-1528649776
where usePathname() and useSearchParams() would return the page we are
navigating to (even if that's an external page wholly unrelated to our
site!).

Fixes #48309, fixes #48438.

link NEXT-1028

Co-authored-by: Jimmy Lai <laijimmy0@gmail.com>
2023-05-03 11:04:53 +02:00
Shu Ding
931c101299
Fix cross-worker revalidate API (#49101)
Currently we invoke the revalidate request directly in the current
server when `res.revalidate()` is called. However app needs to be
rendered in a separate worker so this results in an error of React. This
PR fixes it by sending the request via IPC so the main process will
delegate that to the correct render worker.

Closes #48948.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-03 10:35:34 +02:00
JJ Kasper
e54e38a5a6
Fix edge runtime detection from layouts (#49126)
This ensures we properly handle edge runtime during build when loading pages as currently we are only check the page itself for the runtime flag although it can be nested higher up but we already have the relevant info in the middleware-manifest so we can use that during build. 


Fixes: 
```sh
info  - Linting and checking validity of types
info  - Collecting page data ..ReferenceError: self is not defined
    at Object.<anonymous> (/Users/jj/dev/vercel/next.js/test/e2e/app-dir/app-edge/.next/server/app/edge/basic/page.js:1:1)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at requirePage (/Users/jj/dev/vercel/next.js/packages/next/src/server/require.ts:126:10)
    at <anonymous> (/Users/jj/dev/vercel/next.js/packages/next/src/server/load-components.ts:105:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

> Build error occurred
Error: Failed to collect page data for /edge/basic
```
2023-05-03 08:01:58 +00:00
vercel-release-bot
56de0b2ba8 v13.3.5-canary.5 2023-05-03 06:00:23 +00:00
Shu Ding
0bc1b7ec1c
Skip handler for POST requests when no action ID is found (#49119)
Closes #48204. This shouldn't be a hard error but we should just
silently ignore.
2023-05-02 21:43:47 -07:00
Tobias Koppers
194da0b3e3
add test case for non-enumerable exports (#49106)
### What?

test case for https://github.com/vercel/turbo/pull/4783
2023-05-03 04:23:41 +00:00
vercel-release-bot
3caf6de7a6 v13.3.5-canary.4 2023-05-03 01:01:16 +00:00
JJ Kasper
5cae80dbc8
Tweak app cache handling for paths (#49108)
This updates some handling as discussed and cleans up un-necessary
fields from previous PR.

---------
2023-05-02 17:48:59 -07:00
Tim Neutkens
3cb15a064b
Update create-next-app App Router question (#49111)
<!-- 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 #

-->

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-05-02 17:28:31 -07:00
Shu Ding
2994668bbb
Allow setting runtime in layouts in type declarations (#49117)
Since we're allowing setting `runtime` in layout files, this PR fixes the type guard plugin. Closes #49079.
2023-05-02 23:14:46 +00:00
Jiachi Liu
9102771c65
Optimize non-dynamic metadata routes to static in production build (#49109)
* For sitemap if they're not using dynamic routes generation `generateSitemaps`, should optimize them as static sitemap
* For icons and social images, if they're not using `generateImageMetadata`, should optimize them as static path

Closes NEXT-1071
Fixes #48991
2023-05-02 21:36:44 +00:00
Tobias Koppers
9dc0c1e2ff
improve test case stability (#49036)
### What?

fix bug and stability of test case

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-02 22:10:30 +02:00
Tobias Koppers
fe38369618
add test cases for error handling (#49093)
### What?

test cases for https://github.com/vercel/turbo/pull/4779
2023-05-02 22:09:55 +02:00
Steven
20f90c387c
chore: rename draft mode enabled to isEnabled (#49096)
After trying out draft mode on canary, I realized that it was easy to
select the wrong option from the VS Code intellisense suggestion
dropdown.

So this PR changes `enabled` to `isEnabled` and also wraps in a class to
make the icons for methods look different.

## Before

<img width="545" alt="image"
src="https://user-images.githubusercontent.com/229881/235705729-2be5a5a0-2299-4152-bee7-b6d5659a8d59.png">

## After

<img width="545" alt="image"
src="https://user-images.githubusercontent.com/229881/235733072-338dfb2f-9e27-4d04-b009-a66503efe682.png">
2023-05-02 21:45:28 +02:00
Kiko Beats
d1f77939b2
use ws instead of undici.WebSocket (#49100)
The `WebSocket` constructor exposed by `undici` is not working against some db connections.

That can be considered kind of expected since `undici` docs is saying it's experimental.

We're working into isolate the issue and report at `undici` repository, but for now, let's just use `ws` for all the node versions.
2023-05-02 19:22:05 +00:00
Shu Ding
f3068a5bbb
Add validation to server methods (#49104)
This PR adds a `key` param to the IPC server to validate if a request is from a child process or not.
2023-05-02 18:46:13 +00:00
Maia Teegarden
692d28b193
Update turbopack warning (#49051)
This PR:
* Adds more config keys that should be supported or can be ignored
* Cleans up supported key checking and allows nested keys that aren't experimental
* Removes logging for "only supported options" since the list is much longer now
2023-05-02 17:54:07 +00:00
JJ Kasper
26f69d5ef3
Simplify CNA prompts a bit (#49063)
This updates the default CNA prompts a bit to be more straightforward.

x-ref: [slack thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1681919151818769)
x-ref: [slack thread](https://vercel.slack.com/archives/C04K237UHCP/p1682959312307409)
2023-05-02 17:01:36 +00:00
JJ Kasper
abc74fb92e
Update revalidate handling for app (#49062)
This updates revalidate handling for app and moves some exports from
`next/server` to `next/cache`

x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1682535961644979?thread_ts=1682368724.384619&cid=C042LHPJ1NX)

---------
2023-05-02 08:19:02 -07:00
Tobias Koppers
02c5b5f6d6
find and handle not-found page in app dir (#49095)
### What?

add not-found to the app dir scanning

### Why?

not found pages should be supported

### How?
2023-05-02 15:12:21 +00:00
Tobias Koppers
45d6bb63ef
fix quoted env vars from next config (#49090)
### What?

Avoid quotes around env vars from next.config.js

### Why?

values in `env` in next.config.js got stringified incorrectly
2023-05-02 14:12:46 +00:00
Balázs Orbán
b7d657f525
chore(cli): remove Route Handlers from App Router templates (#49076)
[Slack
thread](https://vercel.slack.com/archives/C04K237UHCP/p1682972426769409)

Closes NEXT-1077

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-02 15:49:09 +02:00
Shu Ding
ee48c66731
Add test case for file uploads (#49048)
This PR adds a test case of handling file inputs in a form.

Fixes NEXT-1062
2023-05-02 14:49:15 +02:00
Tim Neutkens
e76c881d4d
Use route metadata to trace in node-file-trace (#49080)
## What?

Changes the logic for running node-file-trace to no longer rely on
parsing the webpack request. Instead using the module metadata set in
each loader to generate the path.

## How?

The `route` metadata is already provided on all entry loaders since I
added `preferredRegion` support, this can now leverage `route` as well
to generate the required path.

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

-->
2023-05-02 13:15:33 +02:00
vercel-release-bot
d539c764d1 v13.3.5-canary.3 2023-05-02 09:54:31 +00:00
Tobias Koppers
1a2bed2609
allow to use different blur placeholder modes (#49070)
### What?

allows to change blur mode for structured images

also improve performance for static metadata images in app dir by avoiding computing blur placeholder

### Why?

we might want to change the blur mode (in dicussion)

### How?

adds an enum to control the mode
2023-05-02 09:40:00 +00:00
Tobias Koppers
90153ffd8d
update turbopack (#49071)
* https://github.com/vercel/turbo/pull/4691 
* https://github.com/vercel/turbo/pull/4765 
* https://github.com/vercel/turbo/pull/4772
2023-05-02 08:19:30 +00:00
OJ Kwon
e58c63b9ed
fix(next_core): do not apply user config to internal assets (#48210)
### What?
This is necessary changes for the WEB-862, however dependent to https://github.com/vercel/turbo/pull/4521.
2023-05-02 04:49:02 +00:00
Steven
e6acd40cba
feat: make enableUndici: true default and remove node-fetch (#49061)
- Closes #49053

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-05-02 04:10:59 +00:00
Patrick Arminio
a40fa12c50
Remove unused font from tailwind app/page.tsx (#49035)
The font is imported and used in `app/layout.tsx` :)
2023-05-01 20:31:15 -07:00
vercel-release-bot
191e4977a5 v13.3.5-canary.2 2023-05-02 00:31:46 +00:00
lijianan
eea3f34bc2
chore: use includes replace indexOf (#48901)
use includes replace indexOf
2023-05-02 00:07:04 +00:00
OJ Kwon
7b2c79d85e
feat(next-core): support capsize for google font fallback (#48967)
### What?
- closes WEB-800

This PR mimics fallback google font behavior for the turbopack from https://github.com/vercel/next.js/pull/47428, replaces fallback to capsize and adjust read logics.
2023-05-01 23:34:52 +00:00
OJ Kwon
96d68fe351
fix(next-core): interop non string record values in env (#49057)
### What?

Trying to close WEB-718. Since next.config can pass `Record<String, any>` for the env value, explicitly interop it.
2023-05-01 22:38:41 +00:00
Shu Ding
45030d62ad
Fix next dev failing for app when __NEXT_DISABLE_MEMORY_WATCHER is set (#49056)
This env should only affect the teardown & restart process, instead of
the `useWorkers` option. This also solves the problem of running `next
dev` on StackBlitz (which has the env var set:
https://github.com/vercel/next.js/issues/48964#issuecomment-1528569879).

Closes #48964.
2023-05-01 23:40:24 +02:00
Steven
58e5c780f3
feat: add draft mode to next/headers (#48789)
fix NEXT-1003

Co-authored-by: Wyatt Johnson <633002+wyattjoh@users.noreply.github.com>
2023-05-01 21:37:17 +00:00
lijianan
d23b160185
style: remove useless React.Fragment tag on next/image (#48997)
### What?

remove useless React.Fragment tag

### Why?

<img /> is a single element, No need `<></>` as an outer wrapper

### How?
2023-05-01 21:09:03 +00:00
Jimmy Lai
25ba8a74b7
app router: don't unmount/remount on search param changes (#49047) 2023-05-01 20:57:45 +02:00
Shu Ding
905cb5a56b
Rename experimentalReact (#49046)
This PR renames `experimental.experimentalReact` as
`experimental.serverActions` and makes it a hard compilation error if
it's not set but detected server actions.
2023-05-01 20:35:52 +02:00
Ngô Đức Anh
1628260b88
Fixed middleware's edge-chunks not being copied in copyTracedFiles (#48723)
### What?

This PR fixes middleware's edge-chunks not being copied in copyTracedFiles.

### How?

Merging its files' handling with other pages' ones.

### Note

I also want to exclude `process.turbopack` from the unsupported APIs list by checking if `key === 'turbopack'` in `createProcessPolyfill` and `warnForUnsupportedProcessApi`, but I want to have some opinion on this first as I don't know if `process.turbopack` works with the Edge runtime.
2023-05-01 16:43:59 +00:00
Ngô Đức Anh
2d800df099
Fixed next-types-plugin causing Typescript errors when "type": "module" is set (#49027)
### What?

This fixes `next-types-plugin` causing Typescript to complain about CommonJS files importing ESM ones when `"type": "module"` is set but `experimental.typedRoutes` is not enabled.

### How?

Always create a `.next/types/package.json` with `"type": "module"` instead of only doing so when `experimental.typedRoutes` is enabled.

Fixes #49004
2023-05-01 16:19:05 +00:00
Alberto Vilches
2343610fdf
fix: wrong link in docs (#49001)
A link to a third-party package in the docs directs you to the wrong page.
2023-05-01 15:28:50 +00:00
Daniel
37821b54c4
docs: Fix path of '.env.template' (#49012) 2023-05-01 15:23:24 +00:00
vercel-release-bot
95d41fbcb1 v13.3.5-canary.1 2023-05-01 14:23:49 +00:00
Shu Ding
1a71bea612
Fix extra block element in body (#49034)
This PR adds `position: absolute` to the router announcer container so
it won't affect the layout of siblings / parents.

Closes #48087.

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-01 16:02:48 +02:00
Shu Ding
5bc1e65efd
Add flag to switch to the experimental channel (#48896)
This PR does three things:
- Vendors the package `react-server-dom-webpack@experimental` as
`react-server-dom-webpack-experimental` similar to React and React DOM
- Upgrades all vendored React packages
- Re-lands the `experimentalReact` flag to switch between `@next` and
`@experimental` channels of React for app dir.

Fix NEXT-926.
2023-05-01 15:49:10 +02:00
Shu Ding
d3c59a1147
Fix failing test on canary branch (#49038)
Not sure when it was introduced (this was a warning before), but it's
failing on `canary` right now:
https://github.com/vercel/next.js/actions/runs/4851306015/jobs/8645117315
2023-05-01 15:23:14 +02:00
vercel-release-bot
c1f15b0ee6 v13.3.5-canary.0 2023-05-01 12:55:41 +00:00
Tobias Koppers
dbccc794e3
fix GlobalError interop and add test case (#49033)
### What?

fixes handling of GlobalError interop
adds a test case for client component bug

### Why?

app dir client component interop is broken

### Turbopack changes

* https://github.com/vercel/turbo/pull/4597 <!-- Tobias Koppers - add
rspack to our benchmark suite -->
* https://github.com/vercel/turbo/pull/4761 <!-- Tobias Koppers - Do not
use interop logic on proxy modules -->
2023-05-01 14:51:37 +02:00
Alex Kirszenberg
3362851b92
More fluent GraphTraversal API (#49028)
See https://github.com/vercel/turbo/pull/4598

### Turbopack changes

* https://github.com/vercel/turbo/pull/4754 <!-- Justin Ridgewell -
Match TS's extends resolution algorithm -->
* https://github.com/vercel/turbo/pull/4598 <!-- Alex Kirszenberg - More
fluent GraphTraversal API -->

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2023-05-01 14:08:25 +02:00