Use rspack.EvalSourceMapDevToolPlugin when running with Rspack
The modification specifically pass the test case in:
test/integration/server-side-dev-errors/test/index.test.js
Fonts imported in a template module do not preload or preconnect when
used in a template.js file. This PR adds a small fix and a e2e test.
Co-authored-by: Zack Tanner <[email protected]>
## Refactor module graph to reduce memory usage
### What?
This PR refactors the module graph implementation to reduce memory usage by:
1. Changing `graph_idx` from `usize` to `u32` to reduce memory footprint
2. Removing unused fields from `SingleModuleGraphModuleNode` (layer and issues)
3. Moving layer resolution to the point of use in dynamic imports and server actions
This is a small progression in runtime:

### Why?
These changes optimize memory usage in the module graph, which is particularly important for large applications. By removing unused fields and using more compact types, we can reduce the memory footprint of the graph.
Notably, SingleModuleGraphNode is now 24 bytes instead of 48. To make it smaller still we would need to reduce the size of visited moduel, perhaps by storing a reference to the graph that did the original visit? This would be tricky from a lifetimes perspective but much more optimal.
### What?
This PR configures an automated benchmark for turbopack. We can run small benchmarks for all turbopack PRs, and I'll add more benchmarks with follow-up PRs.
### Why?
We need a way to track performance consistently.
This PR updates the `with-supabase` template to better auth pages,
Tailwind v4 and newest `components.json` for full compatibility with
shadcn/ui.
The `(auth-pages)` folder has been removed. For auth, the template is
now using the [password based auth
block](https://supabase.com/ui/docs/nextjs/password-based-auth) from the
Supabase UI Library which makes it easier to update it and keep it
up-to-date.
---------
Co-authored-by: Lee Robinson <[email protected]>
### What?
Split the SST meta data and AQMF into a separate `*.meta` file. A single meta file can contain meta data and AQMFs of multiple SST files.
On database startup only the meta data files need to be read and SST files are lazily mmapped and read only when the AQM-Filter is successful. This ensures that only SST files with a high likelyhood need to be read at all.
Currently this has not much benefit as keys are randomly distributed in SST files, so all files need to be read anyway.
There is a small benefit after a bunch of incremental builds, when some SST files become unused as they have been overwritten.
In future we want to split keys into recently used and not recently used keys and place them in separate SST files. This ensures that less SST files need to be read. This change is a pre-requirement to that change.
Now that `tsc` can be run repeatedly without erroring, we can run it in
watch mode during `pnpm dev` to ensure that type errors are always
up-to-date while developing. Previously, we had to restart `pnpm dev`,
like animals.
Upgrade Rspack to version 1.3.11
This update includes several important improvements and new features:
1. Runtime source map generation
- Pass test cases:
test/production/generate-middleware-source-maps/index.test.ts
2. JS API now provides access to buildInfo.assets
- Pass test cases: test/e2e/app-dir/next-font/next-font.test.ts
3. Full options support for EvalSourceMapDevToolPlugin
4. New built-in CssChunkingPlugin implementation
- Pass test cases: test/e2e/app-dir/css-order/css-order.test.ts
- test dev `test/e2e/app-dir/dynamic-data/dynamic-data.test.ts`
Test fails due to Rspack's lack of support for
`compilation.codeGenerationResults` JS API.
### What?
Remove ` ` (two whitespaces) in intermediate texts.
### Why?
- In dev, browser devtools will provide formatting anyway.
- In production, we are going to parse it again and feed it to the SWC minifier regardless.
### How?
---
x-ref: numbers at https://vercel.slack.com/archives/C06PPGZ0FD3/p1748380301451689
## Refactor Turbopack Compilation Events and Timing Reporting
### What?
This PR refactors how compilation events are created, displayed, and
formatted in Turbopack. It introduces a dedicated `TimingEvent` type for
timing-related messages and improves the formatting of duration
displays.
Additionally we now display all compilation events now that it has been
shown to be stable with no breakages.
### Why?
To provide more consistent and user-friendly output for compilation
events, especially for timing information. The new approach makes
duration formatting more readable by automatically selecting appropriate
units (ms, s, min) based on the duration length.
### How?
- Added a new `TimingEvent` struct that properly formats durations based
on their duration
- Updated the `DiagnosticEvent` constructor to take severity first, then
message
- Improved event handling in the build process to properly categorize
and display different severity levels
- Enhanced file I/O benchmarking to use the new timing event format
- Fixed the formatting of compilation events in the UI
---------
Co-authored-by: Niklas Mischkulnig <[email protected]>
Not all CDNs respect the Vary header when caching. We must assume that
only the URL is used to vary the responses. The Next client computes a
hash of the header values and sends it as a search param.
Before responding to a request, we must verify that the hash matches the
expected value. Neglecting to do this properly can lead to cache
poisoning attacks on certain CDNs.
In this initial PR, the verification I've added only runs during per-
segment prefetch requests, since those are the only ones that both vary
on a custom header and are also cacheable. But for safety, we should run
this verification for all requests, once we confirm the behavior is
correct. Will need to update our test suite, since there are a handful
of unit tests that send fetch requests with custom headers but without a
corresponding cache-busting search param.
It would be even better if we stopped using custom request headers, and
instead fully encoded everything into the search param. At least for
cacheable requests.
This test case has been flaking quite a bit so this increases the fetch
timeout delay as we mainly want to ensure the correct content is
rendered and it works not the duration.
## What?
The reason this test fails seems to be that the `browser.on('request'`
gets registered too late and the requests are not tracked because of
that. Seems it can flake with webpack too. Switched to `beforePageLoad`
to register it always. That switch makes the test consistently pass with
Turbopack too.
The dispatcher will later be the bridge between user code and the dev overlay so it should house all logic that communicates with the Dev Overlay frontend.
May have been a leftover from earlier.
We always consider any throw. Even without a sync stack, we might still have an async stack to show. And even if we have no stack at all, the message is still relevant. Basically, never hide errors.
## Refactor CompilationEventQueue to use enum for event channel types
### What?
Introduces a new `EventChannelType` enum to replace string-based event
channel identification in the `CompilationEventQueue`.
### Why?
This change improves type safety by replacing string-based channel
identification with a proper enum. Using an enum instead of string
literals makes the code more robust and more self-evident in what it's
trying to accomplish.
### How?
- Created a new `EventChannelType` enum with two variants: `Global` and
`Type(String)`
- Updated the `subscribers` map to use `EventChannelType` as keys
instead of strings
- Replaced string literals like `"*"` with the appropriate enum variant
(`EventChannelType::Global`)
- Modified the event subscription and publishing logic to work with the
new enum-based approach
---------
Co-authored-by: Tobias Koppers <[email protected]>
When a server function passes a closure to a method on a closed-over
value (e.g. an array), we must correctly track the value itself so that
it's included in the bound arguments.
For example, in this snippet, `list` must be bound to the server action:
```js
export function Component({ list }) {
return (
<form
action={async () => {
'use server'
console.log(list.find((x) => !!x))
}}
>
<button>submit</button>
</form>
)
}
```
This use case used to work but was accidentally broken by #73189.
fixes#79608fixes#77247
closes NAR-8
## What?
This test is checking a specific path that is not actually sourcemapped
when using webpack either. This won't fail for both webpack/Turbopack
once edge runtime supports sourcemaps.
As noticed in https://github.com/vercel/next.js/pull/79632 we increased
compile times for pages routes in development which is due to us
including the dev-overlay component in the page bundle itself instead of
just in the server runtime.
x-ref: https://github.com/vercel/next.js/pull/79632/files
<details>
<summary>Before</summary>
```sh
✓ Compiled /_error in 1238ms (1385 modules)
✓ Compiled /_error in 1245ms (1386 modules)
✓ Compiled /_error in 1225ms (1394 modules)
✓ Compiled /_error in 944ms (1385 modules)
✓ Compiled /_error in 1232ms (1385 modules)
```
</details>
<details>
<summary>After</summary>
```sh
✓ Compiled /_error in 927ms (1009 modules)
✓ Compiled /_error in 922ms (1010 modules)
✓ Compiled /_error in 935ms (1018 modules)
✓ Compiled /_error in 626ms (1009 modules)
✓ Compiled /_error in 916ms (1009 modules)
```
</details>
## What?
Implements the missing part of the error to make the test pass.
Small difference between webpack/Turbopack is that Turbopack will spot
the conflict earlier and because of that errors earlier too, making the
path still correct but shorter, not a problem in my opinion.
---------
Co-authored-by: Niklas Mischkulnig <[email protected]>
## What?
Currently there's a specific case when you set `runtime:
'experimental-edge'` for `_document.js` or `_app.js` where we
incorrectly write a bundle that is wrapped with the route handling code
to disk. This in turn causes `_document.js` to break during
prerendering. Seems no users ran into this one yet since it was
experimental. This change ensures that we always write the module code
for _app / _document instead. This has no negative effect on edge
runtime modules because those include the direct imports for _app /
_document already in the single route module.