- 08 Sep, 2025 21 commits
-
-
nextjs-bot authored
-
Jiwon Choi authored
-
JJ Kasper authored
This tweaks the output structure a bit and makes types more strong/specific for easier handling. Also adds additional test coverage.
-
Niklas Mischkulnig authored
Don't compile-time-define `process.cwd()` inside of node_modules. This means that node_modules cannot break outside of their individual packages anymore, so in the worst case, a given package includes all of itself, but not anymore the whole project. This means that a `readFileSync(path.join(process.cwd(), "something.txt")))` won't cause that file to be listed in the NFT file anymore.
-
Niklas Mischkulnig authored
Port `EcmascriptInputTransform::GlobalTypeofs` from an extra AST pass to using the `CompileTimeInfo` replacement infrastructure. Ideally, we'd get rid of the `enable_typeof_window_inlining` option entirely. But currently you cannot have different `CompileTimeInfo` per module asset context, so it's not possible to different replacements per directory (which is what we unfortunately want for `typeof window` replacements). Basically closes PACK-5049
-
Tim Neutkens authored
## What? Fixes the flaky build-indicator test to use `retry` instead of `waitFor`. `waitFor` assumes something happens within x amount of time but if that's slightly slower than that it fails the test even though the test is not broken.
-
roottool authored
<!-- 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 # --> ## Summary This PR fixes a typo in `packages/create-next-app/templates/app-api/ts/gitignore`. I fixed it from `commiting` to `committing`. https://github.com/vercel/next.js/blob/8657188505ada96024068b44c6caa5ebd89f3867/packages/create-next-app/templates/app-api/ts/gitignore#L32Co-authored-by:
JJ Kasper <jj@jjsweb.site>
-
Niklas Mischkulnig authored
-
Niklas Mischkulnig authored
- `next_shared/transforms/next_shake_exports.rs`: dead code - `turbopack-ecmascript-plugins/src/transform/modularize_imports.rs`: dead code - `next_shared/transforms/next_page_config.rs`: amp, unsupported anyway - `next_shared/transforms/next_amp_attributes.rs`: amp, unsupported anyway See also https://nextjs.org/blog/next-15-5#amp-support
-
Luke Sandberg authored
## What Casting `ResolvedVc<Box<dyn Module>>` to `ResolvedVc<Box<dyn Module>>` is confusing, so we should reject it. Ditto for no op `upcast`s. This PR makes such calls illegal and eliminates them from the codebase. ## How Introduce a new trait `UpcastStrict` that is only implemented for types that extend or implement different traits. This way we can say it is only valid to try to downcast if the target type is `UpcastStrict`. Then modify the type constraints on our casting utilties to require `UpcastStrict` instead of `Upcast` In the case of `Vc::upcast` i also introduced a `Vc::upcast_non_strict` to help with writing generic code or extension traits. ## Why? I got very confused by some `try_downcast` calls that turned out to be no-ops. Of course this might make some type theorists unhappy, and I don't disagree. Downcasting X->X is a legitimate operation. The ideal solution here would be a linter rule, but there doesn't appear to be any way to implement that.
-
nextjs-bot authored
-
Tim Neutkens authored
## What? It's currently half-sync and half-async. Given this happens in the blocking path when booting in development it's better to use the sync fs version.
-
Jiwon Choi authored
The fallback didn't work because it didn't await the import when returning. x-ref: https://github.com/vercel/next.js/actions/runs/17548458762/job/49837846122 --------- Co-authored-by:
Hendrik Liebau <mail@hendrik-liebau.de>
-
Tim Neutkens authored
## What? This fetch, even though not awaited, was kicked off eagerly and the first `fetch()` in Node.js loads the SSL certificate store which takes roughly 20ms. Made sure that it's only fetched when the version is needed, which is the first time errors happen, and then cached from that point. ### Additional In `test/integration/config-output-export/test/index.test.ts` nearly all tests are flaky because of the way they're structured to do asserts after finally that kills the application. This causes it to race: Either the assertion is correct before it quits or the assertion fails unexpectedly (flaking). This PR fixes the test suite. Accidentally found this flakiness when I made the change in this PR that makes the version step take more than 50 milliseconds the first time. That caused the assertion to be consistently slower, thus reproducing the issue all the time.
-
pontasan authored
**Summary** This PR adds a note to the documentation clarifying the behavior when using external or internal URLs (API Routes) as image sources with Next.js Image Optimization. This change addresses issue #82610. **Details** - Added a note explaining that, for security reasons, request headers are not forwarded to API Routes or external URLs when Image Optimization is used. - Documented that if image data requires authentication, the `unoptimized` property should be considered to disable Image Optimization. **Why** Users may be confused when trying to load images from endpoints that require authentication. This clarification helps developers understand the limitation and how to handle such cases. **References** - [Vercel Changelog: CVE-2025-57752](https://vercel.com/changelog/cve-2025-57752) - [Next.js GitHub Issue #82703](https://github.com/vercel/next.js/issues/82703) --- resolves #82610 --------- Co-authored-by:
Joseph <sephxd1234@gmail.com> Co-authored-by:
Steven <steven@ceriously.com>
-
Jiachi Liu authored
-
Vercel Release Bot authored
This auto-generated PR updates the development integration test manifest used when testing Rspack. Co-authored-by:nextjs-bot <it+nextjs-bot@vercel.com>
-
nextjs-bot authored
-
Hendrik Liebau authored
While dogfooding the debug channel in internal applications, we found bugs (most likely in React) that trigger runtime errors, when the debug channel is used to transport debug information. Those need to be investigated and fixed first, before we can enable the feature by default.
-
Jiwon Choi authored
### Why? Since `next.config.ts` was resolved via require-hook, it had a restriction with Native ESM syntax, like top-level await, dynamic import, and Node.js ESM APIs like `import.meta.url`. There were previous attempts to resolve this via the ESM loader, but those approaches (https://github.com/vercel/next.js/pull/68365, https://github.com/vercel/next.js/pull/83120) ended up adding ~39ms compared to the require-hook due to the loader registration time. However, Node.js natively supports TS since v22.7.0 under the experimental flag, and was enabled by default since v23.6.0. Therefore, this PR feature detects the Node.js version and uses its feature to resolve `next.config.ts` and allows native ESM syntax. As a comparison, the usage of ESM loader vs Native TS on a "Large App": - Duration: ~65% faster (186 ms → 66 ms) - RSS: ~41% lower (80 MB → 47 MB) - Heap: ~78% lower (18 MB → 4 MB) <details><summary>Benchmark Details</summary> <p> | Type | Transpile Duration (ms) | Resident Set Size (MB) | Heap Used (MB) | |---------|--------------------------|------------------------|----------------| | ESM | 186.04 | 79.94 | 17.68 | | Native | 66.09 | 47.32 | 3.81 | | **Δ (Abs)** | -119.95 | -32.62 | -13.87 | | **Δ (%)** | -64.5% | -40.8% | -78.4% | </p> </details> ### How? Used Node.js Native TS support (since v22.7.0). Feature detected with `process.features.typescript` (since v22.10.0), and fallback to the legacy resolution for the current session if it throws. This feature follows the restriction of the Native TS support. The notable restrictions are: - Requires extensions for file imports - Doesn't read tsconfig.json (no import alias) - Requires `with { type: 'json' }` when importing JSON For details, see [Node.js Type stripping](https://nodejs.org/api/typescript.html#type-stripping). See the changes below to get the idea of what is restricted or newly allowed. - Changes to fixtures due to restrictions: https://github.com/vercel/next.js/pull/83240/commits/de1bec89f1976aa6f0cba03aa38cae4c1977abec - Additions to fixtures due to ESM support: https://github.com/vercel/next.js/pull/83240/commits/622a2a828693422aa511793af56734f40569d9f5 Added `next-config-ts-native-ts` tests on CI to run on Node.js v22 and v24. ## Benchmark #### Hello World App - Duration: ~68% faster (102 ms → 32 ms) - RSS: ~65% lower (72 MB → 25 MB) - Heap: ~87% lower (31 MB → 4 MB) <details><summary>Benchmark Details</summary> <p> | Attempt | Transpile Duration (ms) | Resident Set Size (MB) | Heap Used (MB) | |-----------|--------------------------|------------------------|----------------| | CJS 1 | 104.03 | 69.16 | 30.32 | | CJS 2 | 100.35 | 59.95 | 30.14 | | CJS 3 | 100.77 | 75.83 | 32.18 | | CJS 4 | 103.43 | 77.33 | 30.13 | | CJS 5 | 100.82 | 76.30 | 30.22 | | Native 1 | 33.75 | 25.19 | 3.84 | | Native 2 | 28.71 | 21.72 | 3.85 | | Native 3 | 33.49 | 28.95 | 3.85 | | Native 4 | 32.78 | 24.97 | 3.85 | | Native 5 | 33.43 | 24.89 | 3.85 | | **CJS Avg** | 101.88 | 71.71 | 30.60 | | **Native Avg**| 32.43 | 25.14 | 3.85 | | **Δ (Abs)** | -69.45 | -46.57 | -26.75 | | **Δ (%)** | -68.2% | -64.9% | -87.4% | </p> </details> #### Large App > Benchmarked from a large repository that imports packages like `@next/bundle-analyzer`. - Duration: ~56% faster (152 ms → 66 ms) - RSS: ~30% lower (68 MB → 47 MB) - Heap: ~78% lower (17 MB → 4 MB) <details><summary>Benchmark Details</summary> <p> | Attempt | Transpile Duration (ms) | Resident Set Size (MB) | Heap Used (MB) | |-----------|--------------------------|------------------------|----------------| | CJS 1 | 154.35 | 67.73 | 17.16 | | CJS 2 | 148.02 | 61.33 | 17.32 | | CJS 3 | 152.44 | 66.06 | 17.14 | | CJS 4 | 149.89 | 74.33 | 17.17 | | CJS 5 | 156.27 | 68.20 | 17.25 | | Native 1 | 68.01 | 34.66 | 5.51 | | Native 2 | 66.41 | 53.83 | 5.48 | | Native 3 | 62.39 | 45.80 | 1.48 | | Native 4 | 65.20 | 52.02 | 1.35 | | Native 5 | 68.44 | 50.31 | 5.25 | | **CJS Avg** | 152.19 | 67.53 | 17.21 | | **Native Avg**| 66.09 | 47.32 | 3.81 | | **Δ (Abs)** | -86.10 | -20.21 | -13.39 | | **Δ (%)** | -56.6% | -29.9% | -77.8% | </p> </details> Fixes https://github.com/vercel/next.js/issues/67765 Fixes https://github.com/vercel/next.js/issues/71705 Closes [NDX-494](https://linear.app/vercel/issue/NDX-494) --------- Co-authored-by:
vercel[bot] <35613825+vercel[bot]@users.noreply.github.com> Co-authored-by:
graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com> Co-authored-by:
Sebastian "Sebbie" Silbermann <silbermann.sebastian@gmail.com>
-
Hamad Ullah authored
### Fix: [68521](https://github.com/vercel/next.js/issues/68521) Updating outdated with-msw example The [with-msw](https://github.com/vercel/next.js/tree/canary/examples/with-msw) is outdated and doesn't work with the latest msw version. ### What? The [with-msw](https://github.com/vercel/next.js/tree/canary/examples/with-msw) example is outdated and does not work with the latest msw version. ### Why? - msw now uses http instead of rest and the outdated implementation does not work with the latest version anymore. - the client-side worker is now imported through msw/browser. ### How? - replaced all usage of rest with http to align with MSW's new API. - updated the worker import to use msw/browser as per the new structure. ### Media https://github.com/user-attachments/assets/ab9ebb49-28b2-4095-aeea-dcd301093c9f --------- Co-authored-by:
Joseph <joseph.chamochumbi@vercel.com>
-
- 07 Sep, 2025 2 commits
-
-
nextjs-bot authored
-
Vercel Release Bot authored
This auto-generated PR updates the production integration test manifest used when testing Rspack.
-
- 06 Sep, 2025 2 commits
-
-
nextjs-bot authored
-
Zack Tanner authored
When using an unsupported API in a route handler (eg, `export const dynamic` with `cacheComponents` enabled), we were not erroring in dev or failing the build. This is because the transform only asserted on pages & layouts, and not route handlers. This updates the handling to also check route handlers. Fixes NAR-371
-
- 05 Sep, 2025 12 commits
-
-
nextjs-bot authored
-
Vercel Release Bot authored
This auto-generated PR updates the production integration test manifest used when testing Rspack.
-
Hendrik Liebau authored
In dev mode, React is sending debug info (owners, stacks, console logs etc.) from the server to the client so that they can be displayed in dev tools. By default, this info is sent as part of the main RSC payload (inlined into the HTML, or fetched after interaction). With this PR, we're now transporting the debug info in a separate debug channel. This channel currently consists of a unidirectional stream (writable on the server, readable in the client) that is serialized as binary WebSocket messages, which are sent through the existing WebSocket connection that Next.js uses for HMR messages etc. In a follow up, we will also implement the return channel (writable in the client, readable on the server). This allows the client to retrieve debug info lazily and on demand during inspection/introspection. One benefit of this approach is, that it will allow us to change our dynamic validation strategy. We should then be able to tee and cut off the dynamic RSC stream at different points in time (representing the static prerender, runtime prerender, and dynamic render stages), while still letting the complete debug info stream in through the separate channel. This allows us to show the same dynamic validation error details as before, while reducing the number of renders needed to accomplish that. For dogfooding purposes, the feature can be disabled by setting `experimental.reactDebugChannel` to `false`, in case of unexpected regressions in dev mode. ### An implementation note on the request ID handling On the server, at the beginning of the rendering process, we determine a `requestId` and an `htmlRequestId`. 1. The `requestId` is a UUID that's newly generated for each incoming request. 2. The `htmlRequestId` is one of two things: 1. For the HTML request, it's the same as the `requestId`. 2. For subsequent RSC requests (for navigations or server actions), it's the ID of the HTML document from where the request originates. It is sent as the `x-nextjs-html-request-id` request header. The HTML request ID is used to identify connected WebSocket clients. It's sent to the browser as the global `__next_r` variable in the script tag that also includes the initial RSC instructions. The browser sends it back to the server as `id` query param of the WebSocket request. On the server, we store the clients by HTML request ID. When debug chunks are sent to the browser, we use the HTML request ID to look up the correct client. (There's only one client per browser tab/window.) In the browser, we create a debug channel for each request, and we store them keyed by request ID. For the HTML request, the request ID from `__next_r` is used as key. For the RSC requests, the `requestId` is received as `x-nextjs-request-id` response header, and used as key. The server sends the current request ID as part of the WebSocket message to the browser, so that the chunks can be enqueued into the correct debug channel. closes NAR-310 -
nextjs-bot authored
-
Josh Story authored
Prerender interrupted errors are part of the control flow for Next.js applications and aren't intended to be caught by user code. Since we can't avoid it we need to include it in the rethrow API.
-
Jiachi Liu authored
-
Sebastian "Sebbie" Silbermann authored
-
Tim Neutkens authored
## What? Changes in #83331 accidentally changed behavior of how `tsconfig.json` is resolved. When using Next.js we don't want it to be resolved relative to the current file being compiled. It should only use the application root. This PR fixes the behavior to match what it was before and adds a test that fails if it breaks again.
-
Jiachi Liu authored
-
Luke Sandberg authored
This is needed by `prepared_app.rs` to manage subprocesses. Without this we are seeing build breakages in CI e.g https://github.com/vercel/next.js/runs/49662155436 This was triggered by the nix upgrade in #83414
-
Luke Sandberg authored
[turbopack] RFC: Serialize turbopack objects as u16s instead of fully qualified symbol names (#83193) Change the serialization strategy for `ValueTypeId`, `TraitTypeId` and `NativeFunction` to use `u16` values instead of the `global_name` (a fully qualified name of the object). For all these objects the value is the index+1 of the corresponding object in the set of all objects sorted by name. This is a deterministic ordering which should ensure we can deserialize them with the same version of turbopack. Potential concerns with this approach: * debuggability in the Persistent Cache (is this even a thing?) * stability of ids across architectures * if different architectures enable/disable turbotasks then ids will change and make the PC database non-portable. Still this should speed up serialization/deserialization by making everything smaller and faster to encode/decode On an optimized build with a fresh `.next` directory, i measured the size of the `.cache/turbopack/vxxxx` directory `benches/module-cost`: change: 2.38Gb (-22%), wrote in 9.5s, compacted in 5.4s head: 3.06Gb bytes, wrote in 10.3s, compacted in 7.6s `vercel-site` change: 4.8Gb(-12%), wrote in 46ss, compacted in 6.2s head: 5.5Gb, wrote in 48s, compacted in 7.6s So a non-trivial size reduction as expected. This should also speed up encoding/decoding but i didnt attempt to directly measure that. -
Luke Sandberg authored
We are experiencing https://github.com/rust-lang/rust-analyzer/issues/19993 and Rust Analyzer is complaining about our macro gencode. After some trial and error i determined the issue was our use of the `concat!` and specifically the inclusion of the crate name macro so this works around that. Apparently Rust Analyzers implementation of concat! or maybe token tree parsing can get confused by string literals with `-` characters in them. Simply avoiding that for rust analyzer is a reasonable short term workaround
-
- 04 Sep, 2025 3 commits
-
-
nextjs-bot authored
-
Niklas Mischkulnig authored
- Remove dead code back from the old days - Update a few crates Codspeed didn't really have anything breaking in v3? https://github.com/CodSpeedHQ/codspeed-rust/releases
-
Luke Sandberg authored
### What? In #83074 we changed how turbo task objects were registered to use the `inventory` crate. This PR adds a new `inventory_submit!` macro that wraps the existing `inventory::submit` function with a `#[cfg(not(rust_analyzer))]` attribute to prevent Rust Analyzer choking on the generated code. See example error  Because the inventory code does not affect any API surfaces this is safe and if anything should improve rust-analyzer performance
-