Commit Graph
25833 Commits
Author SHA1 Message Date
Tobias KoppersandGitHub 106494de3d [Turbopack] migrate benchmark to new backend (#72457)
### What?

Copy the benchmark to the new backend

Closes PACK-3417
2024-11-13 08:39:52 +01:00
Jude GaoandGitHub 171970d1c6 Re-enable fetch logging test - HMR (#72640) 2024-11-12 19:51:38 -05:00
vercel-release-bot c1377b4f2d v15.0.4-canary.8 v15.0.4-canary.8 2024-11-13 00:38:27 +00:00
0bc2346e83 Fix static indicator for pure IO case (#72639)
Follow-up to https://github.com/vercel/next.js/pull/72631 this ensures
we properly update the `requestStore` when we detect pure IO case and no
dynamic methods are used like `cookies()` or `headers()` e.g. just a
fetch with no caching opts enabled.

---------

Co-authored-by: Zack Tanner <[email protected]>
2024-11-12 16:34:22 -08:00
3c3710bef4 chore: update getting-started/react-essentials path (#72250)
## Description
At #51579, react-essentials.mdx was deleted.
Some URLs doesn't navigate right pages due to this change.
Then I update to correct path.

- Fixes https://github.com/vercel/next.js/issues/72566

---------

Co-authored-by: Sam Ko <[email protected]>
2024-11-12 16:07:47 -08:00
vercel-release-bot ebc36781a5 v15.0.4-canary.7 v15.0.4-canary.7 2024-11-12 23:07:22 +00:00
Sam KoandGitHub 151d07e148 examples: update app-dir-i18n-routing to v15 (#72636)
## Why?

The example `app-dir-i18n-routing` needs to be updated to v15.

## How?

Run the `next-async-request-api` codemod:

```
pnpm dlx @next/codemod@latest next-async-request-api .
```

- Fixes https://github.com/vercel/next.js/issues/72630
2024-11-12 14:29:36 -08:00
b888c4249e improved network url in (dev) cli (#72634)
Continues: https://github.com/vercel/next.js/pull/57882 with added test
and rebased history

Closes: https://github.com/vercel/next.js/pull/57882

---------

Co-authored-by: Ward Werbrouck <[email protected]>
2024-11-12 22:23:31 +00:00
Sebastian "Sebbie" SilbermannandGitHub 0ee45febec Allow usage of Node.js prereleases (#72635)
Local builds of Node.js will be considered prereleases e.g. a local build of Node.js will have `24.0.0-pre` as their version. Now these versions are accepted as long as their base version still matches.
2024-11-12 23:16:34 +01:00
f705f9a1a0 docs(data-fetching): fix static params as promise examples (#72565)
### Improving Documentation

- Since the params prop is now a promise, the type of params in the
generateMetadata and Page components has been changed from `{ id: string
}` to `Promise<{ id: string }>`.

---------

Co-authored-by: JJ Kasper <[email protected]>
2024-11-12 21:10:47 +00:00
YeonHeeandGitHub 23dbf29b08 docs(use-cache): add missing function to page component examples (#72620)
### Improving Documentation

- This PR updates Page component examples by adding `function` keyword
to ensure proper syntax highlighting 🙂
- Also includes the missing `export default` for page components, and
applies consistent code formatting.

<img width="675" alt="image"
src="https://github.com/user-attachments/assets/c081f866-8523-4597-aa56-7baad96eecb5">

<br />
2024-11-12 13:09:06 -08:00
JJ KasperandGitHub dd8c465080 Fix static indicator with dynamicIO (#72631)
This ensures we don't incorrectly update the static indicator status
during the dev warmup render which was causing it to show unexpectedly
with dynamicIO enabled.
2024-11-12 21:01:06 +00:00
1b1cb3eece Add compiler.define option (#71802)
Adds a `compiler.define` option to next.config.js to statically replace
any variables during build-time for Turbopack. This is similar to
Webpack's `DefinePlugin`.

Relates to: https://github.com/vercel/next.js/discussions/71476

---------

Co-authored-by: Tim Neutkens <[email protected]>
2024-11-12 21:13:47 +01:00
Andrew ClarkandGitHub 2b5d8970bd Add experimental clientSegmentCache flag (#72626)
This will be used to gate a rewrite of the client cache that we've just
started. Eventually it should merge with the PPR rollout, but that's
already in active experimentation and we don't want to harm the PPR
rollout. This will also let us incrementally get to parity with the
existing implementation, instead of trying to reach parity in one big
step.

When enabled (and when a route is using PPR), prefetches will use a new
per-segment cache instead of the existing per-page cache.
2024-11-12 19:45:51 +00:00
Jiwon ChoiandGitHub b16f604aff CNA: prompt enable turbopack value to true (#72616)
### Why?

Since Turbopack for dev is stable for v15, enable the prompt value to
true.

Closes NDX-461
x-ref:
[slack-thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1731083893866479)
2024-11-13 04:45:29 +09:00
Hendrik LiebauandGitHub 912d42bbf7 Omit unused args when calling "use cache" functions (#72506)
Using the information byte in a server reference ID, as introduced in
#71463, we can omit unused arguments when calling a `"use cache"`
function. This enables us, for example, to use a cached function in
conjunction with `useActionState` when the function does not need the
previous state, as shown below:

```ts
'use cache'

export async function getCachedRandomValue() {
  return Math.random()
}
```

```tsx
'use client'

import { useActionState } from 'react'
import { getCachedRandomValue } from './cached'

export default function Page() {
  const [result, formAction] = useActionState(getCachedRandomValue, null)

  return (
    <form action={formAction}>
      <p>{result}</p>
      <button>Submit</button>
    </form>
  )
}
```

Previously, in this use case, a new value would have been rendered for
every click. This is because React passes the previous state and the
form data as arguments into the action function. These two arguments are
then included in the cache key, resulting in a new cache key being
generated for every invocation.

_Note: This optimization is currently based purely on the function
signature. It does not yet detect when a param is declared, but not used
in the function body. It's also not yet applied for server actions._
2024-11-12 20:29:10 +01:00
Tobias KoppersandGitHub d81a9f787c [Turbopack] fix bug where task was not recomputed when stale (#72509)
### What?

typo that took me long to find.

We want to check stale flag again when the task lock is acquired again
2024-11-12 20:24:18 +01:00
Tobias KoppersandGitHub 1140e07fc9 [Turbopack] add BackendOptions and allow to disable dependencies, children and storage (#72426)
### What?

Add options for the new backend to disable certain features.

* Storage can be disabled to avoid capturing change log data.
* Dependency tracking can be disabled when no changes are expected and no persistence is used
* Children tracking can be disabled for testing purposes.


Closes PACK-3405
2024-11-12 19:57:27 +01:00
Hendrik LiebauandGitHub 3898a7a99b Include bound args param in server reference information byte arg mask (#72588)
Considering the bound args param in the server reference information byte is required for a client-side optimization of omitting unused arguments to work properly when a server action or `"use cache"` function uses closed-over variables.

The server reference information byte is not used yet, so this PR should not change any observable behavior.
2024-11-12 18:35:16 +01:00
Will Binns-SmithandGitHub 25237efce5 chore: release turbopack npm packages (#72491)
- @vercel/[email protected]
2024-11-12 09:32:11 -08:00
Hendrik LiebauandGitHub 883c337177 Combine bound "use cache" closure args into a single parameter (#72587)
This is a pure refactoring without any behavioral changes. It will allow us to more easily incorporate the presence of the bound args param into the server reference information byte.
2024-11-12 18:02:45 +01:00
Cena KopahiandGitHub b1f1328643 docs: remove unstable_after from Dynamic APIs (#72595)
This pull request removes the unstable_after from the Dynamic APIs, as
it does not cause a route to become dynamic.
2024-11-12 16:54:47 +00:00
Jiwon ChoiandGitHub c469404824 improve no-img-element lint error message (#72410)
### Why?

To customize Image Optimation, the user can use a custom loader, but
that information was out from the related lint error message.

Closes NDX-181
2024-11-12 21:48:12 +09:00
Jude GaoandGitHub d6dd69f210 (e2e) module-level patchFileDelay flag (#72439) 2024-11-12 06:29:03 -05:00
Jam BalayaandGitHub 00de33f86d chore: remove rc from URL (#72599)
## Summary
Get rid of unnecessary `rc.`.
2024-11-12 12:17:01 +01:00
Hendrik LiebauandGitHub 750d7ea633 Bypass source map dev middleware for client chunks (#72581)
A multi-zone Next.js app might have complex rewrites for its client
assets. For these apps, resolving a source map through the
`/__nextjs_source-map` dev middleware might fail because the asset might
belong to a different app.

Instead of trying to resolve those rewrites (i.e. using `fetch` instead
of `fs`), we can just bypass the source map dev middleware for client
chunks. Because we control how those source maps are generated, we can
safely assume that the `sourceMappingURL` is relative to the filename,
with an added `.map` extension. The browser can just request this file,
and it gets served through the normal dev server, without the need to
route this through the source map dev middleware.

reverts #72258
2024-11-12 11:17:57 +01:00
Donny/강동윤andGitHub f8a10c79bf refactor(turbopack): Remove swc_css (#72602)
### What?

Remove `swc_css` from turbopack. It would not break the existing codebase, so it's fine.
2024-11-12 17:36:48 +09:00
Donny/강동윤andGitHub cd82914607 Update swc_core to v5.0.4 from v5.0.1 (#72604)
### What?

Update `swc_core` to `v5.0.4`.

ChangeLog:
https://github.com/swc-project/swc/compare/swc_core%40v5.0.1...swc_core%40v5.0.4

### Why?

To apply https://github.com/swc-project/swc/pull/9734


### How?

Closes PACK-3445
Fixes #72576
2024-11-12 17:36:15 +09:00
Andrew ClarkandGitHub 155471cc20 Move client build ID to a global variable (#72592)
When performing RSC requests, if the incoming data has a different build
ID than the client, we perform an MPA navigation/refresh to load the
updated build and ensure that the client and server in sync.

Currently we store the build ID in the router state, but becauase it's
always in lockstep with the app instance, it's not actually stateful. We
can store it in a global.

The ID gets assigned as a side-effect during app initialization. It
should never change after being set the first time. In practice, because
setAppBuildId is called before hydration starts, it will always get
assigned to the actual build ID before it's ever needed by a navigation.
(If for some reasons it didn't, due to a bug or race condition, then on
navigation the build comparision would fail and trigger an MPA
navigation.)

The logical flow of how the global is assigned is more convoluted than
it should be because we currently decode the Flight stream inside the
React render phase (via a hook), because that's required to propagate
resource hints correctly. Conceptually it would make more sense to
decode the stream before starting hydration and pass the decoded data to
the root component as props; this would also allow us to block hydration
until the id is set. But we'll need to address the hints problem first.

As a follow up, we should probably do the same thing for the App Router
reducer, which is already a global store in practice but is referenced
and passed everywhere as if it were owned by the React tree.
2024-11-11 19:00:34 -05:00
vercel-release-bot 36269e7616 v15.0.4-canary.6 v15.0.4-canary.6 2024-11-11 23:24:03 +00:00
2404b90eed fix: try/catch access to localStorage within __NEXT_APP_ISR_INDICATOR useEffect (#72362)
### What?

Under certain circumstances, the Storage APIs, such as local storage,
are not available.

For example, the Brave browser allows users to block `all cookies`,
which forbids access to local storage.

-
https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage#securityerror

### Why?

When access to local storage fails, the development mode page crashes,
leading to the `Application Error` view.

### How?

Wrap on a try/catch the local storage access done within a use-effect,
under `__NEXT_APP_ISR_INDICATOR`.

There is another local storage access point, but that one is done as
part of `processMessage`, which is called within a `try/catch` block
already.


Fixes #72046

Co-authored-by: JJ Kasper <[email protected]>
2024-11-11 11:47:57 -08:00
0bc4086dff Add expireTag and expirePath APIs (#72485)
This adds `expireTag()` and `expirePath` APIs which are replacing
`revalidateTag` and `revalidatePath`. As such this also marks
`revalidatePath` and `revalidateTag` as deprecated and marked for
removal.

The arguments passed to these methods match `revalidateTag` and
`revalidatePath` with the exception that `expireTag` can receive
multiple tags now as separate arguments which matches our new
`unstable_cacheTag()` API.

We are wanting to update these APIs as `revalidateTag` naming has caused
some confusion as to when the affected items will be updated. The
underlying behavior of `expireTag` is to mark an entry as out of date
and for it to no longer be used so we are expiring it.

If you call `expirePath('/blog/first'`) the next time that item is
requested it is considered expired so the cache will not be used for it
and a fresh entry will be generated. Similarly for `expireTag('posts',
'blog')` the next time any cache with that tag is requested it's
respective cache will not be leveraged and new cache will be populated.

---------

Co-authored-by: Zack Tanner <[email protected]>
Co-authored-by: Delba de Oliveira <[email protected]>
2024-11-11 19:23:39 +00:00
Niklas MischkulnigandGitHub 82ef14c826 Turbopack: Don't run PostCSS on internal assets (#72579)
Closes PACK-3318
Closes https://github.com/vercel/next.js/issues/71618

This is a good idea in general, and also works around a Tailwind bug
breaking `next/font`:
https://github.com/tailwindlabs/tailwindcss/issues/14951
2024-11-11 19:57:37 +01:00
Donny/강동윤andGitHub 12273f5096 fix(turbopack): Remove self-references from tree shaking results (#72567)
### What?

Make the graph acyclic while condensation graphs so that the self-references do not exist.

We are using `condensation` from `petgraph` and it has `make_acyclic: bool` option. I enabled it to make tree shaking a bit faster.

### Why?

Self-reference in the module graph means slower build and needless runtime operations.

### How?

Closes PACK-3439
2024-11-11 20:28:40 +09:00
Jiachi LiuandGitHub d3d0f8125e capture console issues as console errors (#72468) 2024-11-11 12:17:08 +01:00
Vercel Release BotandGitHub 18b357854b Upgrade React from 66855b96-20241106 to 5c56b873-20241107 (#72469) 2024-11-11 10:29:01 +00:00
vercel-release-bot 44d25717a0 v15.0.4-canary.5 v15.0.4-canary.5 2024-11-10 23:24:26 +00:00
91e347910f fix: added cache control headers for static app routes (#72521)
This pull request includes several changes to improve cache control
handling and add new test cases for verifying cache headers in the
standalone mode of the application.

Improvements to cache control handling:

*
[`packages/next/src/server/base-server.ts`](diffhunk://#diff-6f4291cc2bfc5073fdca12a014011769e840ee68583db1468acef075f037015aL3295-R3298):
Updated cache control conditions to check for `undefined` explicitly
before setting cache headers.
[[1]](diffhunk://#diff-6f4291cc2bfc5073fdca12a014011769e840ee68583db1468acef075f037015aL3295-R3298)
[[2]](diffhunk://#diff-6f4291cc2bfc5073fdca12a014011769e840ee68583db1468acef075f037015aL3318-R3324)
[[3]](diffhunk://#diff-6f4291cc2bfc5073fdca12a014011769e840ee68583db1468acef075f037015aR3354-R3365)

New test cases:

*
[`test/production/standalone-mode/required-server-files/required-server-files-app.test.ts`](diffhunk://#diff-0d083b6c7bd3a8a3e9c5ee854123ada3b72db58220d8b65912b047b082f834a2R104-R129):
Added test cases to verify that the correct cache headers are sent for
app routes and app pages.

New static and dynamic route handlers:

*
`test/production/standalone-mode/required-server-files/app/api/test/[slug]/route.js`:
Added a new dynamic route handler with forced static generation.
([test/production/standalone-mode/required-server-files/app/api/test/[slug]/route.jsR1-R7](diffhunk://#diff-1cf8a2cfdbb6473656b2456af0267556270fbbaa7ee2c37e2f3e6c6fed1e4d21R1-R7))
*
`test/production/standalone-mode/required-server-files/app/test/[slug]/page.jsx`:
Added a new static page with a revalidation interval and a function to
generate static parameters.
([test/production/standalone-mode/required-server-files/app/test/[slug]/page.jsxR1-R9](diffhunk://#diff-32038443ca3e4f28db37a6543966397682c64cf6f34e6dd03fd8096414d23022R1-R9))

- Fixes https://github.com/vercel/next.js/issues/65814

Co-authored-by: Janka Uryga <[email protected]>
Co-authored-by: Sam Ko <[email protected]>
2024-11-10 14:22:09 -07:00
vercel-release-bot 0fc77d9681 v15.0.4-canary.4 v15.0.4-canary.4 2024-11-09 23:24:44 +00:00
Sebastian "Sebbie" SilbermannandGitHub 9666c48883 Ensure logged errors in Edge runtime include the stack (#72394)
Bumps `edge-runtime` (and friends to not duplicate dependencies further) to include https://github.com/vercel/edge-runtime/pull/1023
2024-11-09 14:36:21 +01:00
Sebastian "Sebbie" SilbermannandGitHub 2ce4e440bd Expand server-source-maps scenarios to cover Edge runtime (#72288)
...and use test patterns more consistently
2024-11-09 14:19:08 +01:00
Mark KnichelandGitHub 9b78a23b36 Fix the path to the next/experimental/testing/server export (#72527)
The path to the export from the `dist` directory currently doesn't
resolve.
2024-11-09 00:29:43 +00:00
Benjamin WoodruffandGitHub 856e4bf5ce codemod(turbopack): Replace return Err(anyhow!()) with anyhow::bail!() (#72487)
Early returns should use `anyhow::bail!()`.

Ran ast-grep with

```bash
sg run --lang rust --pattern 'return Err(anyhow!($$$ARGS));' --rewrite 'anyhow::bail!($$$ARGS)' --update-all && sg run --lang rust --pattern 'return Err(anyhow::anyhow!($$$ARGS));' --rewrite 'anyhow::bail!($$$ARGS)' --update-all && cargo fmt
```

Manually cleaned up unused import warnings (second commit) because `cargo fix` hangs (idle, no CPU usage) about halfway through our build, and I'm not sure why. I tested the latest nightly, and it hangs too.
2024-11-08 16:17:05 -08:00
vercel-release-bot 0510e3f002 v15.0.4-canary.3 v15.0.4-canary.3 2024-11-08 23:24:36 +00:00
Janka UrygaandGitHub e5ae38355e fix: decrypt bound args before generating a cache key (#72463) 2024-11-08 21:25:09 +01:00
b005bdce38 example: add more files to playwright .gitignore (#72447)
## Description
[create-playwright](https://github.com/microsoft/create-playwright)
makes the below special `.gitignore` file.

```txt
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
```

It's good to add these files to .gitignore for convinience.

### 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: JJ Kasper <[email protected]>
2024-11-08 19:27:48 +00:00
fe77761ee8 docs: fix broken link (#72169)
This PR fixes a broken link.
In my language (Japanese), MDN redirects were not functioning correctly,
so I replaced them with appropriate links.

https://developer.mozilla.org/docs/Web/Events/popstate redirects
https://developer.mozilla.org/ja/docs/Web/Events/popstate (404)

Co-authored-by: Delba de Oliveira <[email protected]>
2024-11-08 19:25:05 +00:00
51ee1c7f59 Fix grammatical error: remove unnecessary 'a' in 03-server-actions-and-mutations.mdx (#72496)
#### Description:
- fix grammatical error: remove unnecessary 'a'

Co-authored-by: Delba de Oliveira <[email protected]>
2024-11-08 11:21:23 -08:00
d8732b9f71 fix: remove unnecessary fragment (#72492)
Hi, Team.

I'd like to contribute as removing unnecessary fragments.
I believe that the fragment will create one more grouping node on
virtual dom, which is not necessary on this example.

If it is essential, please kindly let me know why.

Thank you so much for your support.

### Improving Documentation
- remove unnecessary fragment tags

Co-authored-by: Delba de Oliveira <[email protected]>
2024-11-08 11:21:00 -08:00
691eeae8fb docs: unify the header deps by removing # (#72451)
## Description
Follow up #72391.
I missed some error pages.

### 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: Delba de Oliveira <[email protected]>
2024-11-08 11:20:34 -08:00