Commit graph

15675 commits

Author SHA1 Message Date
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
Donny/강동윤
7e0a6f83f6
chore: Update swc_core to v0.75.41 (#48982)
### What?

Update swc_core and `@swc/core`.

### Why?

https://github.com/vercel/turbo/issues/4747 seems like a critical issue.

### How?

 - Fix WEB-969

### Turbopack changes

* https://github.com/vercel/turbo/pull/4688 <!-- OJ Kwon - ci(workflow):
add appdir underscore test to subset -->
* https://github.com/vercel/turbo/pull/4751 <!-- Justin Ridgewell -
Cleanup "started server on" message -->
* https://github.com/vercel/turbo/pull/4756 <!-- Donny/강동윤 - chore:
Update `swc_core` to `v0.75.41` -->

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2023-05-01 13:15:24 +02:00
vercel-release-bot
48323c9dfe v13.3.4 2023-05-01 10:35:36 +00:00
vercel-release-bot
bc8f5d8afc v13.3.4-canary.0 2023-05-01 10:04:08 +00:00
Tim Neutkens
ec8e0f911f
Ensure app/layout.tsx can export preferredRegion (#49031)
Fixes a small bug where `layout` directly under `app` wasn't considered.
<!-- 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-01 11:58:36 +02:00
vercel-release-bot
0b07616eb2 v13.3.3 2023-05-01 09:07:32 +00:00
vercel-release-bot
b2c6f01242 v13.3.3-canary.2 2023-05-01 07:42:45 +00:00
Shu Ding
97be2e6728
Fix CSS ordering issue with HMR (#49010)
Closes #48807.

The issue seems to be introduced with recent React Float change, which isn't a real problem but a behavior change. Resources are layered by the `precedence` key and the style insertion logic can be simplified as "insert the new stylesheet right after the existing stylesheet in the same layer". When multiple stylesheets are inserted in the same render pass, their new order will be flipped.

This is a nice feature so we can always maintain the order of resources that might conflict.
2023-04-30 20:50:58 +00:00
vercel-release-bot
8e4888f1f6 v13.3.3-canary.1 2023-04-30 18:41:24 +00:00
Shu Ding
acd8735bd4
Update TS plugin type for preferredRegion (#49011)
Related change: #49003. This PR makes sure that these related IntelliSense features are updated:

### Invalid

<img width="842" alt="CleanShot 2023-04-30 at 19 33 06@2x" src="https://user-images.githubusercontent.com/3676859/235367543-3c64ebb9-47fd-48d9-a846-60ec39bf0d3b.png">

### Region (`string`)

<img width="822" alt="CleanShot 2023-04-30 at 19 33 29@2x" src="https://user-images.githubusercontent.com/3676859/235367567-249041cb-9f2b-4693-815d-347ff200244f.png">

### Regions (`string[]`)

<img width="487" alt="CleanShot 2023-04-30 at 19 34 20@2x" src="https://user-images.githubusercontent.com/3676859/235367609-503294d1-ec9b-4d04-9aa7-4e76636eca60.png">

### Docs

<img width="679" alt="CleanShot 2023-04-30 at 19 34 41@2x" src="https://user-images.githubusercontent.com/3676859/235367630-74be18ed-ffc7-4b2d-ae3f-0ad6a187b166.png">
2023-04-30 18:05:50 +00:00
Tim Neutkens
acb9f7a105
Remove unused context providers (#48267)
These were added early on based on some assumptions around how the
params would be passed. In the actual implementation it works
differently so these are just dead code.

<!-- 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-04-30 15:38:04 +02:00
vercel-release-bot
ae00e1206f v13.3.3-canary.0 2023-04-30 13:26:24 +00:00
Tim Neutkens
1d410c808d
Update type of preferredRegion (#49003)
Follow-up to #48959, adds the right types after the renames of
properties.

<!-- 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-04-30 15:21:38 +02:00
Shu Ding
285e77541f
Fix duplicated Edge Runtime warnings (#48987)
When we enable `webpackBuildWorker` this module level `const apiRouteWarnings = new LRUCache({ max: 250 })` will be created in 3 workers, so users will see 4 outputs (last one is static optimization):

<img width="740" alt="CleanShot 2023-04-29 at 20 20 38@2x" src="https://user-images.githubusercontent.com/3676859/235318861-2ec12e30-70b2-4b56-8a2e-df08d130c349.png">

This PR fixes that and now there's only 1.
2023-04-29 22:27:48 +00:00
vercel-release-bot
57878be65f v13.3.2 2023-04-29 19:17:57 +00:00
vercel-release-bot
6668e97666 v13.3.2-canary.14 2023-04-29 17:53:12 +00:00
Tim Neutkens
905b62e599
Fix scroll when loading.js/ts is used (#48986)
### What?

Whenever you navigated and a page suspended through `loading` or an error happened caught by `error` in the first level of segments (e.g. `/dashboard` but not `/dashboard/settings`) scroll would not be applied. This happened because the focus and scroll handling component is rendered as part of `InnerLayoutRouter` and the Suspense / Error boundary was rendered **around** `InnerLayoutRouter`. This behavior is incorrect as we still want to immediately scroll to the place where the loading is rendered.

This PR fixes the behavior by allowing the scroll to apply to loading / error too.

### How?

Moved the scrolling component around the loading/error/innerlayout boundary and added tests.
2023-04-29 17:43:55 +00:00
Jiachi Liu
986039db6e
Update google fonts (#48984)
### What?

* Update google fonts for `next/font` with `scripts/update-google-fonts.js.`
* Add npm script `pnpm update-google-fonts`

### How?

Run `pnpm update-google-fonts`
2023-04-29 15:03:22 +00:00
Donny/강동윤
03189bb2ac
Update resolve rule for @swc/helpers (#48980)
### What?

Update resolve rule for `@swc/helpers` => `node_modules/@swc/helpers` to `@swc/helpers/_` => `node_modules/@swc/helpers/_` to select only `@swc/helpers@v0.5.0`.

### Why?

Previous rule make webpack merge `@swc/helpers@v0.4.x` and `@swc/helpers@v0.5.x`

### How?

Closes WEB-948
Fixes #48593
2023-04-29 12:06:08 +00:00
Tobias Koppers
514d57aefa
add test case for esm commonjs interop (#48940)
### What?

add a test case

### Why?

Some packages expect the default export of a commonjs module to be the whole exports object when importing from ESM.

turbo PR: https://github.com/vercel/turbo/pull/4738
2023-04-29 08:21:04 +00:00
lijianan
861bc0d76c
fix: error when image width={Infinity} (#48855)
This handles the case when `Infinity` is passed to the Image `width` prop
2023-04-29 06:42:28 +00:00
Tobias Koppers
f2b920b218
add image metadata for svg (#48947)
### What?

add .svg to the list of images that that return metadata

### Why?

.svg files should also return width and height

### How?

see https://github.com/vercel/turbo/pull/4741
2023-04-29 06:13:32 +00:00
Justin Ridgewell
b33179cce2
Cleanup "started server on" message (#48972)
We bind to an IPv6 unspecified address (`::`), which makes the old message say "started server on :::3000", and that's kinda ugly. The new message will say "[::]:3000".
2023-04-29 05:46:42 +00:00
vercel-release-bot
e66c6250ce v13.3.2-canary.13 2023-04-28 22:55:36 +00:00
Josh Story
4f5f4769e5
preload fonts using ReactDOM.preload (#48931)
This PR updates the way we preload fonts. Previously we tracked which
fonts we needed to preload for each layer and rendered a `<link
rel="preload" href="..." as="font" />` tag for each preloadable font.
This unfortunately gets blocked by data fetching and we want to be able
to hint these preloads as soon as possible. Now that React support Float
methods in RSC we can use `ReactDOM.preload(..., { as: "font" })` to
implement this functionality

This PR makes the following changes
1. expose a `preloadFont` method through the RSC graph
2. expose a `preconnect` metho through the RSC graph
3. refactor the preloads generation to use `preloadFont` instead of
rendering a preload link
4. If there are no fonts to preload but fonts are being used in CSS then
a `preconnect` asset origin is called instead of rendering a preconnect
link
5. instead of emitting a data attribute per font preload indicating
whether the project is using size-adjust we now emit a single global
meta tag. In the future we may get more granular about which fonts are
being size adjusted. In the meantime the current hueristic is to add
`-s` to the filename so it can still be inferred.

In the process of completing this work I discovered there were some bugs
in how the preconnect logic was originally implemented. Previously it
was possible to get multiple preconnects per render. Additionally the
preconnect href was always `"/"` which is not correct if you are hosting
your fonts at a CDN. The refactor fixed both of these issues

I want to do a larger refactor of the asset loading logic in App-Render
but I'll save that for a couple weeks from now

Additionally, the serialized output of preloads now omits the word
anonymous when using crossorigin so tests were updated to reflect
`crossorigin=""`

Additionally, tests were updated to no longer look for the size-adjust
data attribute on preloads

Additionally, There is a note about leaving a `{null}` render in place
to avoid a conflict with how the router models lazy trees. I'll follow
up with a PR addressing this

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-04-29 00:50:20 +02:00
Tim Neutkens
799a05ce8f
Support preferredRegion and Support runtime/preferredRegion on layouts (#48959)
### What?

Implements resolving of `runtime` and `preferredRegion` in layouts. It
will resolve from the root layout down, each layout can override
`runtime` or `preferredRegion`.

```
app
├── layout.js -> export const runtime = 'edge'
├── page.js -> Edge runtime
└── dashboard
    ├── page.js -> Edge runtime
    └── settings
        ├── layout.js -> export const runtime = 'nodejs'
        └── page.js -> Node.js runtime
```

Adds support for `preferredRegion`. This is similar to `export const
config = { region: ['sfo1'] }` in `pages`.

However, there is a difference. It supports `export const
preferredRegion = 'home'` and `export const preferredRegion = 'edge'`.
`home` refers to the configured default region on your deployment
platform and `edge` refers to "all regions".

### How?

I've implemented a temporary resolving in `entries.ts`.
`preferredRegion` is tracked through the entry module in webpack which
is why it's added to all the loaders that create an entry module, this
prevents having to resolve/parse again later on.

Fixes NEXT-880
Fixes NEXT-1064
Fixes #48905
Closes #48933
2023-04-28 17:40:34 -05:00
JJ Kasper
7bfd582999
Ensure WebSocket is polyfilled for node runtime as well (#48924)
Follow-up to https://github.com/vercel/next.js/pull/48870 this exposes
WebSocket for the Next.js runtime so we don't have divergence in APIs as
discussed with @cramforce
2023-04-28 15:48:14 -05:00
JJ Kasper
d922e3d483
Remove un-necessary undici warnings (#48970)
These warnings aren't actionable by users so this removes them from our
compiled undici version.

x-ref: [slack
thread](https://vercel.slack.com/archives/C04R82GSDBN/p1682704853867449?thread_ts=1682624317.557059&cid=C04R82GSDBN)
2023-04-28 14:19:18 -05:00