Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] canary from vercel:canary #2040

Open
wants to merge 5,598 commits into
base: canary
Choose a base branch
from
Open

[pull] canary from vercel:canary #2040

wants to merge 5,598 commits into from

Conversation

pull[bot]
Copy link

@pull pull bot commented Mar 27, 2024

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 💖 Please sponsor : )

mknichel and others added 26 commits November 1, 2024 10:54
… routing (#70731)

This PR adds some testing utilities for testing `middleware` and
`next.config.js`. The goal is to make it easy for anyone to add tests
that assert the behavior of routing, such as how
`next.config.js#redirects`, `next.config.js#rewrites`, and `middleware`
interact, or what paths are matched by middleware. This is useful to
catch routing issues before the code ever reaches production.

This code is exported in a new `next/server/testing` export to keep it
separate from the rest of the `next/server` code.

This testing code is marked as `unstable_` since it is not reusing all
of the same code that the actual routing in `next dev` and `next start`
is using. It is an approximation to make unit testing easier.

# Middleware

A new `unstable_doesMiddlewareMatch` function was added to assert when
middleware will be run for a path.

```js
import { unstable_doesMiddlewareMatch } from 'next/server/testing'

expect(
  unstable_doesMiddlewareMatch({
    config,
    nextConfig,
    url: '/test',
  })
).toEqual(false)
```

Helpers were also created to test for whether the response was a
redirect or rewrite.

# Next.config.js

A new `unstable_getResponseFromNextConfig` function was added to run
`headers`, `redirects`, and `rewrites` functions from `next.config.js`,
calling them in the order that they would actually be executed in.

```js
import { getRedirectUrl, unstable_getResponseFromNextConfig } from 'next/server/testing'

const response = await unstable_getResponseFromNextConfig({
  url: 'https://nextjs.org/test',
  nextConfig: {
    async redirects() {
      return [{ source: '/test', destination: '/test2', permanent: false }]
    },
  },
})
expect(response.status).toEqual(307)
expect(getRedirectUrl(response)).toEqual('https://nextjs.org/test2')
```

---------

Co-authored-by: Zack Tanner <[email protected]>
Co-authored-by: JJ Kasper <[email protected]>
… when constructing a cell (#72113)

Cell contents are immutable once constructed, so there's no chance that they'll grow in size again. Common collections can be shrunk to avoid storing empty spare capacity in this case (note: if they're already correctly sized, `shrink_to_fit` bails out early).

**Result:** This gives a ~1.4% decrease in top-line peak memory consumption, for a theoretical CPU/Wall time cost that's too small to measure.

**Inspiration:** The inspiration for this was vercel/turborepo#2873, which decreased task storage (not the top-line memory usage?) by ~14%, vercel/turborepo#8657, and other similar optimization PRs.

## Additional Opportunities

- There may be more places where cell are constructed (e.g. persistent storage deserialization) where a cell's `SharedReference` is constructed that is not currently captured by this.
  - Depending on the library used, deserialization may already construct exact-sized collections.
  - As an additional example, manually constructing a `ReadRef` and converting it into a cell skips this optimization because `ReadRef::cell` internally uses the type-erased shared-reference `raw_cell` API which is incompatible with this optimization. We could special-case that in the `ReadRef::new_owned` constructor (not in `ReadRef::new_arc` though), but nobody should be manually constructing `ReadRef`s.

- We still don't use `shrink_to_fit` on `RcStr` types. Some of these are in-place extended (when they have a refcount of 1) with `RcStr::map`, so we probably don't want to be too aggressive about this to avoid `O(n^2)` time complexity blowups.

## Memory Benchmark Setup

```bash
cd ~/next.js
cargo run -p next-build-test --release -- generate ~/shadcn-ui/apps/www/ > ~/shadcn-ui/apps/www/project_options.json
pnpm pack-next --project ~/shadcn-ui/apps/www/
```

```bash
cd ~/shadcn-ui
pnpm i
cd ~/shadcn-ui/apps/www/
heaptrack ~/next.js/target/release/next-build-test run sequential 1 1 '/sink'
heaptrack --analyze ~/shadcn-ui/apps/www/heaptrack.next-build-test.3604648.zst
```

### Memory Before (canary branch)

First Run:

```
peak heap memory consumption: 3.23G
peak RSS (including heaptrack overhead): 4.75G
```

Second Run:

```
peak heap memory consumption: 3.23G
peak RSS (including heaptrack overhead): 4.75G
```

### Memory After (this PR)

First Run:

```
peak heap memory consumption: 3.18G
peak RSS (including heaptrack overhead): 4.74G
```

Second Run:

```
peak heap memory consumption: 3.19G
peak RSS (including heaptrack overhead): 4.73G
```

This is about a 1.4% decrease in top-line memory consumption.

## Wall Time with `hyperfine` (Counter-Metric)

This is theoretically a time-memory tradeoff, as we'll spend some time `memcpy`ing things into smaller allocations, though in some cases reducing memory usage can improve cache locality, so it's not always obvious.

```
hyperfine --warmup 3 -r 30 --time-unit millisecond '~/next.js/target/release/next-build-test run sequential 1 1 /sink'
```

This benchmark is slow and takes about 30 minutes to run.

Before:

```
Benchmark 1: ~/next.js/target/release/next-build-test run sequential 1 1 /sink
  Time (mean ± σ):     56387.5 ms ± 212.6 ms    [User: 107807.5 ms, System: 9509.8 ms]
  Range (min … max):   55934.4 ms … 56872.9 ms    30 runs
```

After:

```
Benchmark 1: ~/next.js/target/release/next-build-test run sequential 1 1 /sink
  Time (mean ± σ):     56020.9 ms ± 235.4 ms    [User: 107483.8 ms, System: 9371.8 ms]
  Range (min … max):   55478.2 ms … 56563.6 ms    30 runs
```

This is a ~0.65% *reduction* in wall time. This is small enough (<2 standard deviations) to likely just be noise.

## Wall Time with `turbopack-bench` (Counter-Metric)

```
cargo bench -p turbopack-bench -p turbopack-cli -- "hmr_to_eval/Turbopack CSR"
```

Gives:

```
bench_hmr_to_eval/Turbopack CSR/1000 modules
                        time:   [15.123 ms 15.208 ms 15.343 ms]
                        change: [-0.8471% +0.4882% +1.9719%] (p = 0.55 > 0.05)
                        No change in performance detected.
```

Using https://github.com/bgw/benchmark-scripts/

In practice, it's not really possible to measure changes in wall time <1%, so this is within "noise" territory (as noted in the criterion output).

Closes PACK-3361
Since prefetching is disabled in development, seeding the prefetch cache
for the initially rendered page can lead to an inconsistent navigation
experience, where the initially visited page won't behave the same as
subsequent pages that you navigate to.

We should ultimately get to a place where the prefetch behavior is
consistent between dev/start to keep the production behavior as
consistent as possible with the development experience, but when we do
so, we would want to enable it across the board.

This happens to fix a bug with dynamicIO because the server-patch action
(which happens when data is missing for a rendered segment) was
mismatching the router state tree, which triggers a hard navigation to
recover. This happens to fix the issue because the router never hits the
server patch case, which is when the hard navigation could occur.
Separately, we're working to verify why the seeded prefetch entry might
have caused this change in behavior only in dev.

Note: this modifies a navigation test that was asserting on RSC requests
taking place, which will now happen in dev as there'll be no prefetch
entry.

Fixes #72150
This PR fixes two issues on the
[cacheLife](https://nextjs.org/docs/canary/app/api-reference/functions/cacheLife)
documentation page:

1. Incorrect highlight for `biweekly` in [Defining reusable cache
profiles](https://nextjs.org/docs/canary/app/api-reference/functions/cacheLife#defining-reusable-cache-profiles)
section. It should highlight `biweekly` but not `export default async
function Page()`


![image](https://github.com/user-attachments/assets/f5b331cf-a5eb-41b0-8cba-08b2a2ff836d)

2. Missing `switcher` for TS and JS codeblock in [Defining cache
profiles
inline](https://nextjs.org/docs/canary/app/api-reference/functions/cacheLife#defining-cache-profiles-inline)
section. Codeblock is displayed twice


![image](https://github.com/user-attachments/assets/e618f806-674f-4c21-8e02-8c90dd2308a5)

Signed-off-by: Eng Zer Jun <[email protected]>
Co-authored-by: Jiwon Choi <[email protected]>
…g Additional Arguments` section in `Server Actions and Mutations` docs (#72226)

This PR adds a missing TypeScript/JavaScript code switcher to the
[Passing Additional
Arguments](https://nextjs.org/docs/canary/app/building-your-application/data-fetching/server-actions-and-mutations#passing-additional-arguments)
section in the [Server Actions and
Mutations](https://nextjs.org/docs/canary/app/building-your-application/data-fetching/server-actions-and-mutations)
documentation. This enhancement improves accessibility for users by
providing both TypeScript and JavaScript code examples, making it easier
for developers to follow along in their preferred language.


![image](https://github.com/user-attachments/assets/d8225abc-c1d0-478f-afc1-6830f83587c4)

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

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

### Adding or Updating 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: Jiwon Choi <[email protected]>
## Summary
[`NextAuth.js`](https://next-auth.js.org/) is becoming
[`Auth.js`](https://authjs.dev/)!
Then update new documentation link.

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

Co-authored-by: Zack Tanner <[email protected]>
### What?

Fix the `expire` time for `cacheLife('seconds')`.

### Why?

The intended `expire` time is 1 minute, but the actual time is 1 second.

### How?

Times are expressed in seconds, so change `1` to `60`.

Co-authored-by: Zack Tanner <[email protected]>
### What?

Fix `ident` implementation of `EcmascriptModuleFacadeModule`. Previous code replaces original module part, while the new implementation adds part information as a modifier.

### Why?

Currently, `ident` implementations are not correctly aligned. This makes some modules returned from `references()` disappear from the final bundle.

### How?
### What?

When fetch fails we don't want to cache that persistently, but only for the session.
…nks (#72258)

When using Turbopack, and importing a server action into a client
component, the source map for the client chunk will be requested if
devtools are open. The filename for this source map request might be
`/_next/static/chunks/[project]__800ed2._.js`, for example. This
scenario was already handled by the dev middleware.

However, it didn't consider that there might also be an `assetPrefix`
defined in the `next.config.js`. In this case, the filename would be
`/some-asset-prefix/_next/static/chunks/[project]__800ed2._.js`. When
resolving the external source map for this file, we need to strip the
asset prefix.

Again, this can only be tested manually.
Recently we updated the implementation of validating dynamic behavior
with dynamicIO for prerenders and this updates the dev validation logic
to largely match.
### What?

I need to get the list of failing tests and diff the test result of this approach, which is the original idea of #71692, with the `__turbopack_original__` idea, which is the current idea behind #71692

### Why?

### How?

 - Closes PACK-3307
### What?

Implement r/w/rw optimization for tree shaking.

### Why?

This can reduce the number of fragments or at least the number of `references()` call
### What?

Do not store `export *` in internal fragments.

### Why?

It results in large number of fragments.

### How?

Closes PACK-3264
This addresses @bgw’s feedback for #72043:

- Defers cloning
#72043 (comment)
- Uses a `BTreeSet` in `FontAxesWeights::Fixed` to ensure it’s always
sorted, rather than sorting at url-generation-time
#72043 (comment)
- `RcStr` `.to_owned()` -> `.clone()`

Test Plan: Unit tests

Co-authored-by: Benjamin Woodruff <[email protected]>


Closes PACK-3360

Co-authored-by: Benjamin Woodruff <[email protected]>
This PR updates the SIGTERM and SIGINT exit codes to 143 and 130
respectively. These updated codes are what other tooling, such as
Nx/Turborepo, expects when running commands that did not completely
successfully due to receiving SIGTERM and SIGINT.

For Nx, the SIGINT (e.g. `Ctrl+C`) causes a bad build cache. Both Nx and
Turborepo will have bad cache when SIGTERM is received, which can happen
in a CI environment if a job times out, runs out of memory, etc.

I have a [repo here](https://github.com/jaysoo/next-cli-signals) that
demonstrates the wrong behavior with Turborepo. By exiting with the
wrong code, it can result in bad cache in CI or Docker.

Closes: #62906

---------

Co-authored-by: Sam Ko <[email protected]>
Co-authored-by: Zack Tanner <[email protected]>
Follow up to #71113.

This generates a prefetch response for route segments, so the client can
request them individually, and reuse shared layouts between separate
page prefetches.

Since this is exclusive to PPR, segment prefetches are always static and
do not reach the application layer. They are served directly from cache.
(This part was implemented in the previous PR.)

The prerendered segment data is generated (and revalidated)
simultaneously with the prerender of the entire page, to ensure
consistency between parent and child segments. Since we always rebuild
the whole page, we can save an extra render of each segment by reusing
the Flight response that was used to generate the initial HTML.

We do this by decoding the page data using a server-side Flight
consumer, picking out an individual segment's data, then re-encoding it
as its own Flight response. We have to do this once per segment — not
ideal, but for now it's the only way to make sure the side effects from
the original Flight stream (e.g. Float preloads) are transferred to the
per-segment streams.

This PR does not yet include any updates to the client router.
sokra and others added 30 commits November 13, 2024 08:39
### What?

Copy the benchmark to the new backend

Closes PACK-3417
### Why?

PR #72311 bumped the repo's TS to 5.6.3 but missed out on the packages
that added TypeScript to their own at #71256.
### Why?

`next/font` depends on the Google Fonts metrics from the
`@capsizecss/metrics`. Added support for Geist at
seek-oss/capsize#217, so we update version.

### How?

- Bump `@capsizecss/metrics` to 3.4.0
- Update the test to match the metrics.

#### Bonus

- Modified the test to use `.toMatchInlineSnapshot` to identify and
update future changes more easily.

### RFC

The `@capsizecss` team is planning to [automate the updating
process](seek-oss/capsize#217 (review)).
Should we continue to depend on them or replace them with our custom
script to fetch Google Font API (requires API key)?

x-ref: #47115
x-ref: [Twitter
Feedback](https://x.com/illyism/status/1855500917589602706)
The option was always set to `true` so we can safely remove it. The
experimental `serverActions` flag was removed a long time ago in #57145.
Observable in `pnpm next dev test/development/app-dir/dynamic-io-dev-errors/` and `/no-accessed-data`. It only affects the bottom stacks in that particular stack so assertions are not viable yet until the full stack is properly sourcemapped.
### Why?

Following up on #72752, the ESLint
fix suggestion for `react/no-unescaped-entities` rule was added at
jsx-eslint/eslint-plugin-react#3831, released on
[v7.37.0](https://github.com/jsx-eslint/eslint-plugin-react/releases/tag/v7.37.0).
Therefore, we bump the `eslint-plugin-react` version to `^7.37.0`.
Tests have been inconsistent due to flaky build-time failures caused by
AMP validation errors:
https://github.com/vercel/next.js/actions/runs/11807856104/attempts/1.

We’re updating the library version with the expectation that this will
resolve the issue.

```
info: undefined
   Generating static pages (9/37) 
   Generating static pages (18/37) 
   Generating static pages (27/37) 
Error occurred prerendering page "/amp-hybrid". Read more: https://nextjs.org/docs/messages/prerender-error
AssertionError: Assertion failed: WebAssembly is uninitialized
    at new module$contents$goog$asserts_AssertionError (evalmachine.<anonymous>:102:1441)
    at module$contents$goog$asserts_doAssertFailure (evalmachine.<anonymous>:103:354)
    at goog.asserts.assertExists (evalmachine.<anonymous>:104:374)
    at Object.module$contents$amp$validator_validateString [as validateString] (evalmachine.<anonymous>:2238:108)
    at Validator.validateString (/tmp/next-install-89c7ccfd9a04886e2e88ccffb9ad709b236d4b8c8398fcdbb34c9c897118b9e9/node_modules/.pnpm/next@file+..+next-repo-99a8e0af0510a7a2958e71c9affe3d5d83d452a304c40ea8b352506d74651d57+packa_6sb2ai4rhstsynpbl53dxgpt7e/node_modules/next/dist/compiled/amphtml-validator/index.js:17:2057)
    at validateAmp (/tmp/next-install-89c7ccfd9a04886e2e88ccffb9ad709b236d4b8c8398fcdbb34c9c897118b9e9/node_modules/.pnpm/next@file+..+next-repo-99a8e0af0510a7a2958e71c9affe3d5d83d452a304c40ea8b352506d74651d57+packa_6sb2ai4rhstsynpbl53dxgpt7e/node_modules/next/dist/export/routes/pages.js:100:34)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async exportPagesPage (/tmp/next-install-89c7ccfd9a04886e2e88ccffb9ad709b236d4b8c8398fcdbb34c9c897118b9e9/node_modules/.pnpm/next@file+..+next-repo-99a8e0af0510a7a2958e71c9affe3d5d83d452a304c40ea8b352506d74651d57+packa_6sb2ai4rhstsynpbl53dxgpt7e/node_modules/next/dist/export/routes/pages.js:134:17)
    at async Span.traceAsyncFn (/tmp/next-install-89c7ccfd9a04886e2e88ccffb9ad709b236d4b8c8398fcdbb34c9c897118b9e9/node_modules/.pnpm/next@file+..+next-repo-99a8e0af0510a7a2958e71c9affe3d5d83d452a304c40ea8b352506d74651d57+packa_6sb2ai4rhstsynpbl53dxgpt7e/node_modules/next/dist/trace/trace.js:153:20)
    at async exportPage (/tmp/next-install-89c7ccfd9a04886e2e88ccffb9ad709b236d4b8c8398fcdbb34c9c897118b9e9/node_modules/.pnpm/next@file+..+next-repo-99a8e0af0510a7a2958e71c9affe3d5d83d452a304c40ea8b352506d74651d57+packa_6sb2ai4rhstsynpbl53dxgpt7e/node_modules/next/dist/export/worker.js:336:18)

```

Note that this failure breaks the production integration test almost 10%
of times.

![CleanShot 2024-11-12 at 23 15
11@2x](https://github.com/user-attachments/assets/89ad041c-22b1-47ad-aa56-58ea3a269811)
### Why?

ESLint v8 is deprecated. Also, it's deprecated dependencies spam npm
warning.


![image](https://github.com/user-attachments/assets/856a70a5-3185-44d6-9fa9-c773f898dc25)


Closes NDX-208
#72641)

This PR adds a new example that shows a more complex use case where you
don't want browser to know about the upstream image server so instead
you can proxy through a serverless function.

Some use cases might be checking for an IP address, user agent, etc.
### Why?

As Google Font added Geist, replace the CNA local font
with`next/font/google`. Added `subsets` value as the font will be
preloaded. Removed`weight` value as:

> An array of weight values if the font is not a [variable google
font](https://fonts.google.com/variablefonts). It applies to
next/font/google only.

x-ref: https://nextjs.org/docs/app/api-reference/components/font#subsets
x-ref: https://nextjs.org/docs/app/api-reference/components/font#weight

Closes NDX-462
### What?

Use proper logic to depend on the side-effect-import node from the import-binding nodes in **graph construction phase**.

### Why?

We previously used a workaround based on a hash map with the module specifier as the key, but as I'm going to optimize the graph, we need to store every dependency information in the graph so that the optimizer can use information.

### How?

Closes PACK-3444
`redirect` in server actions has handling to support relative redirects
(eg `redirect('./foo')`) but it doesn't handle a multi-level relative
path, eg `redirect('../foo')`.

This used to work by accident because the invalid URL would be handled
as an error and then would trigger an MPA navigation. In Next 15, it
surfaces an actual error because we are less tolerant to them.

Fixes #72765
Closes NDX-479
## What does this PR do?

According to [Installation
docs](https://nextjs.org/docs/getting-started/installation#automatic-installation),
[create-next-app](https://nextjs.org/docs/app/api-reference/cli/create-next-app)
messages are below

![image](https://github.com/user-attachments/assets/bb20d031-a8f0-4306-8c41-d3341fa8c899)

However, the real messages are

![image](https://github.com/user-attachments/assets/828f7e15-8284-4b97-a62f-d99867aede09)

Unlike the `src/`, `next dev` and `@/*` don't have single quotation.
So I add apostrophes to create-next-app message.

## How did you verify your code works?

I have tested local build package.

![image](https://github.com/user-attachments/assets/f358cf89-8bf1-48aa-97f9-2f097e4ef753)

Co-authored-by: JJ Kasper <[email protected]>
We run flake detection on PRs to help catch flaky tests before they hit
canary, but we currently only run flaky test detection in Webpack and
not Turbopack. This is problematic because there's sufficient forking
logic in tests for the different bundlers & we've seen a high likelihood
of a test to flake more frequently in one bundler vs another due to
things like differing compilation speeds and differing implementation of
core features.

This will add some additional time to this CI job to account for needing
to run the tests 6 times, but will hopefully catch things before they
become a problem later. I think we could also consider reducing the
number of times per bundler to be 2 if it turns out to be adding too
much time.

This updates the flake detection job to run the tests multiple times in
Turbopack as well.

CI run:
https://github.com/vercel/next.js/actions/runs/11822662639/job/32940264160?pr=72773
## Summary
Follow up #72636.
Bump 13 → 15 version in the description.

### Adding or Updating Examples

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

---------

Co-authored-by: samcx <[email protected]>
## Description
I have corrected some mistakes according to the [contribution
guide](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md).

1. Update `create-next-app` script
2. Remove redundant new line, space and double colon
3. `readme.md` → `README.md`

### Adding or Updating Examples

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

---------

Co-authored-by: Sam Ko <[email protected]>
### What?

Follow-up from review comments
## Summary
Sync
[`04-functions`](https://github.com/vercel/next.js/tree/canary/docs/01-app/03-api-reference/04-functions)
file convention.

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


### Adding or Updating 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: Sam Ko <[email protected]>
### What?

Tailwind CSS [supports an ESM
config](https://tailwindcss.com/docs/configuration#using-esm-or-type-script)
file.
This PR changes `tailwind.config.js` to `tailwind.config.mjs`.

### Why?

1. To convert one more file to ESM
2. To use the modern format
3. To follow other similar migrations that have taken place in the
Next.js codebase (e.g. `next.config.mjs`)

### How?

1. Change file extensions from `.js` to `.mjs`
2. Change module format from CommonJS to ESM

Co-authored-by: Sam Ko <[email protected]>
### What?

fix some bugs when counting collectibles
When `next dev` is started with `-p 0` or `PORT=0` – which is probably
unusual in userland, but is the default for our tests – a random port is
selected for the dev server. If the user, after starting the dev server,
then changes the `next.config.js` file, the dev server detects that and
automatically restarts. For the restart, the original port config is
used, resulting in a random port being selected again. This will most
likely be a different port than was selected before, and so reloads in
the browser won't work. It also results in `ERR_CONNECTION_REFUSED`
errors in our tests that use `patchFile` to change the `next.config.js`
content.

To fix that issue, we're now storing the automatically selected port
when the dev server has started initially, and are re-using it for any
subsequent automatic restarts.
…ed (#72781)

Using a build error instead of a runtime error allows us to fail early,
and show a proper error source in the terminal and in the dev overlay.

<img width="777" alt="Screenshot 2024-11-13 at 22 19 45"
src="https://github.com/user-attachments/assets/d0ee3c69-71f5-4aa6-8c0a-879217f66930">
## Why?

There is a type issue with one of the form actions.

```
app/(auth-pages)/sign-up/page.tsx:42:25 - error TS2322: Type '(formData: FormData) => Promise<{ error: string; }>' is not assignable to type 'string | ((formData: FormData) => void | Promise<void>) | undefined'.
  Type '(formData: FormData) => Promise<{ error: string; }>' is not assignable to type '(formData: FormData) => void | Promise<void>'.
    Type 'Promise<{ error: string; }>' is not assignable to type 'void | Promise<void>'.
      Type 'Promise<{ error: string; }>' is not assignable to type 'Promise<void>'.
        Type '{ error: string; }' is not assignable to type 'void'.

42           <SubmitButton formAction={signUpAction} pendingText="Signing up...">
```

- x-ref: #72778
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.