Commit graph

17126 commits

Author SHA1 Message Date
JJ Kasper
9a6ae144a9
Update swc runners config (#53939)
This fixes unexpected cache hits occurring causing latest next-swc
changes to not be built for the docker based builds. Noticed in our
turbo run summaries for these builds that no input files were detected
most likely due to older Node.js/pnpm versions being used from the old
Docker image.

This also updates to leverage new runner labels for better build perf
cutting build times down from over an hour down to around 20 min.

Fixes build issue on aarch64-linux-musl due to `TurboMalloc` not being
able to resolve. Test build done here
https://github.com/vercel/next.js/actions/runs/5850893681/job/15860929304

x-ref:
https://github.com/vercel/next.js/actions/runs/5843580924/job/15845848384

x-ref:
https://github.com/vercel/next.js/actions/runs/5837652747/job/15833506858
x-ref:
https://github.com/vercel/next.js/actions/runs/5837652747/job/15833506925
x-ref:
https://github.com/vercel/next.js/actions/runs/5837652747/job/15833507067
x-ref:
https://github.com/vercel/next.js/actions/runs/5837652747/job/15833507135
2023-08-13 19:02:48 -07:00
vercel-release-bot
261db496f7 v13.4.14-canary.3 2023-08-12 21:41:13 +00:00
Hüsrev
5cda9af70f
The extra word 'the' has been deleted (#53951) 2023-08-12 21:37:51 +00:00
Zack Tanner
23f623546e
add "expect" to list of forbidden IPC headers (#53947)
`expect` is an unsupported header for undici: c83b084879/lib/core/request.js (L354) -- this filters it out so that the API routes don't throw an internal server error if that header is included. 

Also added a test case for the previously submitted PR that was added for `content-length: 0`

- x-ref: #53843

Fixes #53822 (erroneously closed by a content-length issue being fixed)
2023-08-12 19:38:38 +00:00
Josh Story
2b38118ea0
Update React ot latest canary (#53881)
Updated React from cb3404a0c to f359f9b41.

### React upstream changes

- https://github.com/facebook/react/pull/27191
- https://github.com/facebook/react/pull/27209
- https://github.com/facebook/react/pull/27199
- https://github.com/facebook/react/pull/27218
- https://github.com/facebook/react/pull/27217
- https://github.com/facebook/react/pull/27212
2023-08-12 17:20:14 +00:00
Jiachi Liu
4056994304
Recover not found errors from flight data to render with proper boundary (#53703)
### What?

We change the not-found rendering strategy to the origin one which recovers the not found error from the flight data, and hit the error boundary to display the closet not found component.

For parallel `@slot` we shouldn't pass down the not-found boundary, the boundary is only for `@children`.

### Why?

We're having a lot of not-found matching issues that manually searching for not found and layout won't be accurate as we have various scenarios like `(group)` routes, dynamic routes, etc.

### How?

Only render html with empty body so that the error can recover from flight and render the proper not-found component during hydration.

One change for metadata is that we need to get the "not-found" metadata in the initial render, so we'll catch the not-found error once there first and start render the "not-found" metadata and put it in the flight data. Then when it recovers it's still preserved.

Fixes #53694
2023-08-12 08:41:47 +00:00
Kevin Pham
ea0bb97729
Docs: fix pnpm command for saving dev deps (#53937) (#53938)
Previous of after (before in linked issue)
```
❯ pnpm add --save-dev @next/eslint-plugin-next
Already up to date
Progress: resolved 525, reused 517, downloaded 0, added 0, done
Done in 6.4s
```

Resolves #53937
2023-08-12 07:52:46 +00:00
Artur Bień
e0ca2ba544
feat(image): DataURL placeholder support for <Image /> (#53442)
Adds support for base64-encoded `placeholder`. Enables using placeholders without the "blur" effect.

Fixes #47639
- [x] Add support for DataURL placeholder
- [x] Add tests
- [x] Update docs

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-08-11 23:45:20 +00:00
Dima Voytenko
4c14482553
[chore] Upgrade playwright to 1.35.1 (#53875) 2023-08-11 23:25:01 +00:00
Donny/강동윤
c802075827
Update swc_core to v0.79.55 (#53831)
### What?

Update swc crates to 54f38cb47e

### Why?

To apply minifier bugfixes.

### How?

Closes WEB-1358
Fixes #53723

---

turbopack counterpart: https://github.com/vercel/turbo/pull/5699
2023-08-11 22:38:44 +00:00
Leah
ddc8f50d24
enable @vercel/og support for turbopack (#53917)
### What?

Now that we have wasm support (and support for `?module`) `@vercel/og` should be supported

### Turbopack updates

* https://github.com/vercel/turbo/pull/5677 
* https://github.com/vercel/turbo/pull/5660 

Closes WEB-138
2023-08-11 22:16:41 +00:00
Banbarashik
424b205344
fix typo (#53908)
remove misused pronoun "it"

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-08-11 21:59:31 +00:00
JJ Kasper
2312852e57
Update runner labels (#53925)
Adds a new label for distinguishing between runners, also fixes a couple flakey fixtures noticed while benchmarking.
2023-08-11 21:05:11 +00:00
Shu Ding
707b1e3bc3
Limit sharp's concurrency (#53385)
Sharp by default spawns #cpu_cores threads to process images which could lead to large memory consumption. This PR caps the `concurrency` value especially on dev.

Locally I see a small memory improvement (10~20 MB) from this, but it will mostly affect long-running servers.

Related: https://github.com/lovell/sharp/issues/2607

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-08-11 20:21:41 +00:00
Shu Ding
10cb74062b
(docs) Fixes Server Actions example (#53920)
Closes #53910.
2023-08-11 18:25:31 +00:00
Justin Ridgewell
fe80aff6dc
Turbopack: Emit whether server or client assets changed (#53879)
### What?

Updates the new `entrypoint.changed()` method to signal whether the server or client assets changed. Now, a `{ changed: 'server' | 'client' | 'both' }` will value will be yielded by the subscription.

### Why?

So that client-only changes can be handled differently than server-only changes.

### How?

We just needed to track the server and client output assets separately, so that we can detect changes to either individually. It's difficult to tell what `Vc` change triggered a recomputation on the Rust side (I'd have to involve mutable `State` into the Vc), and it's also hard to re-emit a duplicate value (eg, if a client change follows a client change, we need 2 emits). Instead, I tie the two different `server_changed()` and `client_changed()` functions into a single enum on the TS side.

Depends on https://github.com/vercel/next.js/pull/53809, since I don't want to introduce merge conflicts while Tobias is on vacation.
2023-08-11 18:08:33 +00:00
Jiachi Liu
50ff54ee29
Use summary_large_image as twitter card if images present by default (#53919)
This is an improvement for twitter card, if there's image present we could use `summary_large_image` to make the twitter card look better instead of using `summary` by default, so that users could benefit from the large image card display on twitter
2023-08-11 17:52:45 +00:00
Jan Nicklas
9e1e9bf311
Fix/match resource (#53796)
### Bug Fix
fixes #53366



### Change

Add `query` and [`matchResource`](https://webpack.js.org/api/loaders/#inline-matchresource) to the module mapping. 



### Why

`mod.resource` and all other paths inside `packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts` are already using the query:

e127c51327/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts (L506-L507)

e127c51327/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts (L584-L585)



### Motivation

We are using a static extraction css-in-js solution which uses the [inline match resource feature](https://webpack.js.org/api/loaders/#inline-matchresource) (see more in #53366)

As a css-in-js file contains the TSX and the CSS code we have to split the file into two modules which share the same `resource.path`.  

This works well however there is a problem in the mapping inside `.next/server/app/page_client-reference-manifest.js`.
The `ssrModuleMapping` from `addSSRIDMapping` in 
e127c51327/packages/next/src/build/webpack/plugins/flight-manifest-plugin.ts (L270) links to the latest module (the css part) and not the the initial one (the js part).

Therefore the css module is rendered [react-server-dom-webpack](https://www.npmjs.com/package/react-server-dom-webpack/v/0.0.1?activeTab=versions) and breaks.

The SSR/SSG fails with the error `Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.`

Co-authored-by: Shu Ding <3676859+shuding@users.noreply.github.com>
2023-08-11 17:36:58 +00:00
Justin Ridgewell
85da585d1f
Turbopack: Fix debugging in napi for next-api (#53889)
### What?

#51883:

> Node.js sets stdout to non-blocking by default, rust expects it to be blocking
> 
> so when logging a lot of data, it can happen that rust receives an error while writing causing it to panic, the error is just that the resource is temporarily unavailable, but rust doesn't handle this case
> 
> See https://github.com/napi-rs/napi-rs/issues/1630

### Why?

### How?

This moves the work done in #51883 into the `loadBindings` function used by both next-api and next-dev.
2023-08-11 17:13:40 +00:00
Shu Ding
599cde8631
Add @heroicons/react to modularizeImports (#53902)
As discussed [here](https://vercel.slack.com/archives/C0591D8EN4C/p1691752316347649?thread_ts=1691743605.677919&cid=C0591D8EN4C), there're other popular icon and component libraries to be added until we have a better solution.
2023-08-11 14:49:13 +00:00
vercel-release-bot
9229f74b86 v13.4.14-canary.2 2023-08-11 12:02:35 +00:00
Delba de Oliveira
1cafeb4102
Docs: Update confusing wording in intercepting routes (#53854)
Fixes: https://github.com/vercel/next.js/issues/53787
2023-08-11 08:59:03 +00:00
Tobias Koppers
45576ae752
Turbopack: more tests and bugfixes for next.rs api (#53809)
### What?

* adds more HMR test cases
* fixes bugs found

### Why?

### Turbopack changes

* https://github.com/vercel/turbo/pull/5668 <!-- OJ Kwon - ci(test):
temporarily increase test timeout -->
* https://github.com/vercel/turbo/pull/5696 <!-- Tobias Koppers -
Cleanup minify -->
2023-08-11 10:29:36 +02:00
Colin McDonnell
7e16538485
Include instructions for bun package manager (#53590)
## For Contributors

### Improving Documentation

- [x] Run `pnpm prettier-fix` to fix formatting issues before opening the PR.
- [x] Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide

### What?

Add instructions for using `bun/bunx` where relevant. I only added mentions where npm/yarn/pnpm were all already listed. 

### Why

Bun can be used as a runtime-agnostic [package manager](https://bun.sh/package-manager) and script runner in any project with a `package.json`.

(Sorry, I probably should have consolidated this with https://github.com/vercel/next.js/pull/53467)

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-08-10 23:44:20 +00:00
Dave Carlson
9bb10b1cb3
Delete errorneous empty content length header (#53843)
fixes https://github.com/vercel/next.js/issues/53822

PR https://github.com/vercel/next.js/pull/53368 introduced a regression causing fetch with custom headers to fail in safari.
There are known issues with uncidi when a content-length: 0 header exists.

When performing a custom fetch in safari, this header is present.
When performing a custom fetch in chrome, this header is not present.




Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2023-08-10 22:03:13 +00:00
Steven
6f7ffadc86
fix: normalize backslash in getStaticPaths() for windows (#53876)
This normalizes the backslash for windows users who accidentally use `\` in the request paths instead of the expected `/`.

For example, in https://github.com/nodejs/nodejs.org/pull/5617 the slash was hardcoded for split that caused the backlash to remain the the `getStaticPaths()` result.

- Fixes #51225
2023-08-10 21:27:02 +00:00
Steven
2cf5d3a8aa
chore(docs): note cache-control header for preview/draft mode (#53825)
You can technically get similar ISR behavior setting the `Cache-Control` in `getServerSideProps()`, but this won't be automatically bypassed when enabling Preview Mode or Draft Mode so this PR adds that to the documentation.

x-ref: [slack discussion](https://vercel.slack.com/archives/C03S8ED1DKM/p1691514209722429)
2023-08-10 14:05:54 +00:00
Lee Robinson
1286e145b0
docs: Opting out of scrolling with next/link and useRouter. (#53804)
Addressing comments from https://github.com/vercel/next.js/issues/49087.
Introduced with https://github.com/vercel/next.js/pull/51869.
Related https://github.com/vercel/next.js/issues/50105.

This PR adds documentation for `next/link` and useRouter` about how to disable scroll restoration.
2023-08-10 09:41:56 +00:00
Tim Neutkens
d4ff236f48
Reuse RenderWorker type (#53782)
Found that this type was duplicated. This just reuses the existing definition.
2023-08-10 04:35:33 +00:00
Steven
89be8c4b35
chore(docs): add missing "try it out" (#53815)
Follow up to https://github.com/vercel/next.js/pull/53760

This follows the same pattern as other demo links on this page.
2023-08-10 00:30:56 +00:00
JJ Kasper
6bd8cd7cac
Ensure we set cache-control: no-cache for actions (#53824)
This ensures we don't accidentally allow caching server actions causing unexpected behavior.
2023-08-09 23:59:42 +00:00
Lucas Constantino Silva
0350e00d0d
docs: document cache tagging mechanism (#53806)
This PR document the cache tagging semantics in Next.js, and how to benefit from it during cache revalidation.
2023-08-09 23:18:02 +00:00
Luud Janssen
5fe332186e
Add changeFrequency and priority attributes to sitemaps (#48484)
Closes #48479. 

Couldn't find the source for the Next.js beta docs, so I didn't add documentation.

Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
2023-08-09 20:36:22 +00:00
Zack Tanner
712669f605
improve error message for conflicting parallel segments (#53803)
This is a follow-up to log both conflicting paths & a link to route group docs, which I believe is the only scenario someone could trigger this

- https://github.com/vercel/next.js/pull/53752
2023-08-09 17:21:24 +00:00
JJ Kasper
7d67f00f8f
Sort root entries per pageExtensions config for consistency (#53769)
While running our `test/integration/middleware-src` test suite across
systems, noticed this behaved inconsistently due to us relying on the
order the filesystem ordered duplicates e.g. `middleware.ts` and
`middleware.js`.

Considering we already have a loud warning for this duplicate this adds
consistency across systems by ensuring these are sorted per our
pageExtensions order which is `ts` takes priority over `js` by default.

An additional test case was not added as the above mentioned suite
covers this but was verified as passing on one of the systems (mac OS)
where it was not previously.
2023-08-09 09:54:55 -07:00
Lee Robinson
3077a0e9ff
docs: Add more information about Server Actions (#53805)
A few helpful additions based on conversations I've had recently.
2023-08-09 15:48:24 +00:00
Steven
87301834b3
chore: add light/dark mode theme detection to image component example (#53760)
This PR adds documentation for light/dark mode detection with `next/image`.

In the future, we could also document the picture solution once https://github.com/vercel/next.js/pull/51205 goes stable (although some of the preloading would not be possible).

* x-ref: https://twitter.com/victorbayas/status/1688596439704780822
2023-08-09 14:55:42 +00:00
Balázs Orbán
6809edccd5
chore(actions): exclude drafts from PR notificiation (#53669)
### What?

Do not count draft PRs

### Why?

These are still being worked on
2023-08-09 14:38:49 +00:00
Delba de Oliveira
8e0d108836
Docs: Add option for fetching data using route handlers - from the client (#53793)
In the data fetching page, we discuss the different ways you can fetch data in Next.js. This PR adds a fourth option which is to call route handlers from client components. I've also added a note that you shouldn't call a route handler from a server component. 

Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2023-08-09 13:55:44 +00:00
OJ Kwon
e127c51327
test(turbo): allow to run test with --experimental-turbo (#53396)
### What?

Allows to configure test runs with --experimental turbo.
2023-08-09 05:48:54 +00:00
JJ Kasper
6b492974b7
Move next-rs API tests from unit to e2e (#53771)
These tests aren't unit per-se as they rely on e2e-utils so this moves
them to the `development` test folder.

x-ref: [slack
thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1691520079363229)
2023-08-08 21:50:04 -07:00
Emilien Kenler
64d9475f37
Fix typo in data fetching documentation (#53772)
Fix a typo in data fetching documentation.
2023-08-09 04:45:49 +00:00
JJ Kasper
4b4533787b
Add warnings for static generation bail outs (#53761)
Currently using server actions on a page or using edge runtime causes
that page to bail out of ISR or static generation so this adds warnings
to make users aware of this.

x-ref: [slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1690816539472449)

---------

Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2023-08-08 20:09:34 -07:00
Vercel Release Bot
5c9553002c
Update font data (#53759)
This auto-generated PR updates font data with latest available
2023-08-09 01:10:50 +00:00
MrAdib
2566d0781d
Fix a link in incrementalCacheHandlerPath.mdx (#53718)
fix the default cache handler link
2023-08-09 00:55:13 +00:00
Eric Fennis
5e716ec918
fix: Update outdated transform imports lucide-react (#53697)
### What?

Fixing outdated import mapping with the latest `lucide-react` changes. See [lucide-icons/lucide@v0.264.0](https://github.com/lucide-icons/lucide/releases/tag/v0.264.0)

Closes: lucide-icons/lucide#1482

### Why?

Import mapping was outdated

### How?

By updating the default config and the tests.

## Notes

Maintainer here from @lucide-icons.
To this day I didn't know the Nextjs default config file has predefined hardcoded modularize imports. 
I was a bit surprised that there is a default mapping for libraries that could change in the future like Lucide. 

I'm not in favor of this hardcoded "modularize imports", because this creates a hard dependency on libraries. With Lucide, we still have not reached 1.0 and will sometimes rename icons and add aliases for them. So issues will occur in the future, and constantly updating this config doesn't feel right. 

Is there, not a better way? Like for example, a package exposing a config file containing the import mapping?
This way import map will automatically be in sync with changes in a package. 

Let me know what you think of this.
2023-08-09 00:48:48 +00:00
Josh Story
79b7c1493b
App Router Preinitialize all required scripts except one for bootstrap (#53705)
Currently all scripts that are required for every page are loaded as
part of the bootstrap scripts API in React. Unfortunately this loads
them all as sync scripts and thus requires preloading which increases
their priority higher than they might otherwise be causing things like
images to load later than desired, blocking paint. We can improve this
by only using one script for bootstrapping and having the rest
pre-initialized. This only works because all of these scripts are
webpack runtime or chunks and can be loaded in any order asynchronously.

With this change we should see improvements in LCP and other metrics as
preloads for images are favored over loading scripts

Co-authored-by: Steven <steven@ceriously.com>
2023-08-08 17:28:17 -07:00
Zack Tanner
d58fd68f0a
fix parallel route tests & improve error for conflicting pages (#53752)
This fixes some tests that were disabled due to a missing `page` segment for the corresponding slots in `/parallel/nested`. 

While fixing, I also noticed if you accidentally create two pages that resolve to the same URL segment (which is fairly easy to do accidentally do with route groups), we were throwing an unhelpful error of "Cannot find module: '<snip>/page_client-reference-manifest.js'" when building (and fail silently in dev). For example, this scenario was throwing a manifest error:

```
app
  (groupa)
    page.tsx
  (groupb)
    page.tsx
```

This will now throw with a more helpful error when resolving parallel segments if the page segment was already resolved. This also re-enables the disabled tests.

Closes NEXT-1440
Fixes #53569 (by virtue of throwing a more helpful error)
2023-08-08 22:56:39 +00:00
Dingan(Will) Wang
5cfb936edd
Fix example/with-material-ui broken links (#53707)
Fixed the example/with-material-ui broken links.

It seems the external websites got updated.
2023-08-08 22:37:41 +00:00
Steven
195d1f1a2b
fix(next/image): priority in App Router causes double fetch on mobile (#53700)
The root cause is `ReactDOM.preload()` inserts `<link rel="preload">` above the `<meta name="viewport">`. 

This PR adds a test to prove that upgrading React fixes the issue (see commits).

- Depends on https://github.com/facebook/react/pull/27201
- Depends on https://github.com/vercel/next.js/pull/53742
- Fixes https://github.com/vercel/next.js/issues/53574
- Related https://github.com/vercel/next.js/issues/52995
2023-08-08 21:02:54 +00:00