100 Commits
Author SHA1 Message Date
Niklas MischkulnigandGitHub d3e41fb496 Move outputHashSalt out of experimental (#95840)
Keep reading `config.experimental.outputHashSalt` for now to not break
existing adapters until they are migrated.
2026-07-20 16:34:58 +02:00
Niklas MischkulnigandGitHub 756d6dc9ea Move immutable static assets config option out of experimental (#95351)
Keep reading `config.experimental.supportsImmutableAssets` for now to
not break existing adapters until they are migrated.

Closes NAR-868
2026-07-20 15:35:14 +02:00
Niklas MischkulnigandGitHub 1a7e6bda0f chore: Remove stale build warning (#95813)
Added in https://github.com/vercel/next.js/pull/88001
But it doesn't actually work. It thinks the build is always stale
2026-07-15 18:40:46 +00:00
Niklas MischkulnigandGitHub b3480cfdd5 Respect NEXT_HASH_SALT for server side assetsHashes (#95738)
Also respect the hash salt for `assetsHashes`
2026-07-15 11:28:06 +02:00
Niklas MischkulnigandGitHub 7c6f1318e0 docs: Improve immutable static docs (#95752)
This statement was unnecessarily strict
2026-07-14 13:16:41 +02:00
Niklas MischkulnigandGitHub d774f7db29 Upgrade to swc 73 (#95731)
- [x] Waiting for a swc major bump in
https://github.com/swc-project/plugins...
2026-07-14 08:03:43 +02:00
Niklas MischkulnigandGitHub 93249ee06d Fix Pages router 404 runtime rendering with Adapter (#95264)
The problem is that the adapter expected a `output.pages` for the `/404`
route so that it can add these files to other Pages handlers so that
they can render a 404 at runtime (getStaticProps with
revaliate/getServerSideProps):


https://github.com/nextjs/adapter-vercel/blob/650effd340b4f676a9bca6e0cdaba9bf7d34595a/packages/adapter/src/outputs.ts#L421-L438

https://github.com/nextjs/adapter-vercel/blob/650effd340b4f676a9bca6e0cdaba9bf7d34595a/packages/adapter/src/node-handler.ts#L331-L340

But this 404 Pages handler was not actually emitted if it was
prerendered, where it only emitted the `/404.html` static file. But
that's not what the adapter needs.

Tests:
1. Run as an e2e test
2. Add a variant with dynamically rendered 404 pages

Full e2e test run:
~~https://github.com/vercel/next.js/actions/runs/29081105397~~
https://github.com/vercel/next.js/actions/runs/29087851475

Closes NEXT-4947
2026-07-13 09:56:16 +02:00
Niklas MischkulnigandGitHub db1f3a64da Fix duplicate static files in adapter (#95681)
When using `nextConfig.i18n`, then static files for `404.html` and
`500.html` were added multiple times to the list.

These duplicate entries in `outputs.staticFiles` ended up causing race
conditions in the Vercel adapter because the same output file path was
written concurrently by multiple file operations.
2026-07-13 09:44:27 +02:00
Niklas MischkulnigandGitHub 3ebd45b154 docs: Immutable static assets (#95348)
<!-- 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

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

### Signed commits

- This repository requires verified commit signatures on protected
branches.
- If this pull request is blocked for unsigned commits, re-sign the
commits and force-push the branch.
- A `Signed-off-by` line in the commit message is not enough.


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

-->
2026-07-10 10:54:55 +02:00
Niklas MischkulnigandGitHub dd27732f54 Turbopack: enable import with {type: 'text'} by default (#95606)
It's time: https://github.com/tc39/proposal-import-text/issues/12
2026-07-08 18:02:21 +02:00
Niklas MischkulnigandGitHub da06078b9b test: Fix immutable static asset deployment tests for real (#95600)
https://github.com/vercel/next.js/pull/95550 wasn't enough:

-
https://github.com/vercel/next.js/actions/runs/28907225463/job/85769093204
-
https://github.com/vercel/next.js/actions/runs/28907225463/job/85769093252

Because `VERCEL_IMMUTABLE_STATIC_FILES_ENABLED` might be set, but it
still only works when using adapters, so it broke in the non-adapter
deploy test jobs.

Also prepare for when we switch the default of `NEXT_ENABLE_ADAPTER` by
setting it explicitly to `0` for when we want to test the old CLI
builder.
2026-07-08 14:16:35 +02:00
Niklas MischkulnigandGitHub 8b5df172e4 test: Fix immutable static asset deployment tests (#95550)
1. The env var ended up having a different name than I foresaw months
ago. Now `next.assetToken` is correctly `undefined` if the deployment
used immutable static assets.
2. `expect(searchParams.get(...)).toBe(undefined)` was failing because
`.get()` returns null for unknown keys

Failures:
-
https://github.com/vercel/next.js/actions/runs/28831699621/job/85515363446
-
https://github.com/vercel/next.js/actions/runs/28831699621/job/85515363310
2026-07-07 16:53:46 +02:00
Niklas MischkulnigandGitHub cb94fd9c59 docs: Fix testing-adapters variable name (#95575)
https://github.com/vercel/next.js/blob/b3278b7573bd305268fd2e2125946158e4b048db/test/lib/next-modes/base.ts#L313
2026-07-07 16:43:05 +02:00
Niklas MischkulnigandGitHub b3278b7573 test: Use Turbopack for 'Test new and changed tests when deployed' (#95552) 2026-07-07 16:03:00 +02:00
Niklas MischkulnigandGitHub 8cc2bd1e3d test: Disable service worker deploy tests for now (#95570)
They were failing. Sam will look into these

-
https://github.com/vercel/next.js/actions/runs/28831699621/job/85515363343
-
https://github.com/vercel/next.js/actions/runs/28831699621/job/85515363453
-
https://github.com/vercel/next.js/actions/runs/28831699621/job/85515363420
2026-07-07 16:02:31 +02:00
Niklas MischkulnigandGitHub f51577ae81 ci: Bump withgraphite/graphite-ci-action (#95562)
- https://github.com/withgraphite/graphite-ci-action/pull/50
- https://github.com/withgraphite/graphite-ci-action/pull/51
2026-07-07 13:26:25 +00:00
Niklas MischkulnigandGitHub 775ee37b5e Run instrumentation for Node.js Middleware without Adapter (#95547)
Fixup for #95357

`.handler()` is used by adapters
but `.default()` (=`internalHandler`) is the legacy entrypoint and used
by the non-adapter setup

Also needs https://github.com/vercel/vercel/pull/16944
2026-07-07 14:02:02 +02:00
Niklas MischkulnigandGitHub 0c70a7c3a0 test: Fix service worker error test (#95548)
- One of them tests that an error is thrown. Don't run the deployment
test there
- The other tests are still broken when deployed, but we will fix that
separately
2026-07-07 08:43:52 +02:00
Niklas MischkulnigandGitHub 3e11c728e5 Upgrade to swc 72 and rust-react-compiler (#95536)
Fixes #95257
Fixes #95372
2026-07-07 07:27:34 +02:00
Niklas MischkulnigandGitHub 143926d6a2 Disable supportsImmutableAssets with config.output (#95521)
`output=export` and `output=standalone` don't use adapters.
But for `supportsImmutableAssets`, you really want the adapter to get
all necessary data.

Disable immutable assets for now in this case. Once `output=export` runs
the adapter (as it should), we can remove this override again
2026-07-06 21:39:01 +02:00
Niklas MischkulnigandGitHub 100606da48 trace-viewer: Support string span ids in nextjs trace backend (#95515)
The vercel CLI's trace format is 99% the same as the Next.js
`.next/trace` format. Except that it's using UUID as span ids, instead
of numbers.

1. Run `pnpm next internal trace
.vercel/output/diagnostics/cli_traces.json`
2. Profit
<img width="1434" height="265" alt="Bildschirmfoto 2026-07-06 um 15 23
02"
src="https://github.com/user-attachments/assets/b1cc0a8d-a1d3-4135-884b-e3050514853f"
/>
2026-07-06 18:13:18 +02:00
Niklas MischkulnigandGitHub c2b5142640 otel: Use correct parent span for Node.js middleware (#95306)
Node.js Middleware was inheriting the wrong parent span (and behaved
differently compared to Edge runtime Middleware)

`Middleware.execute` and `BaseServer.handleRequest` should be sibling
spans (depending on context, both are root spans). Previously
`BaseServer.handleRequest` had a child span `Middleware.execute`

Depends on https://github.com/vercel/next.js/pull/95357 to make the
direct entrypoint test pass
2026-07-06 14:53:45 +02:00
Niklas MischkulnigandGitHub 70165e9d59 Fix instrumentation hook awaiting for middleware with adapters (#95357)
#94306 fixes this for pages, but middleware was still broken when
deployed via adapters

Coming from https://github.com/getsentry/sentry-javascript/issues/21713

Now the instrumentation test suite takes 11m to run in deployment mode
though....
2026-07-06 14:21:11 +02:00
Niklas MischkulnigandGitHub e7c04f670f Also rewrite requires in page templates with Webpack (#95446)
Thus far, it wasn't possible to use `require()` in a template file with
Webpack.
But I needed to add a `if(NEXT_RUNTIME !== "edge") { const x =
require("../../something"); }`

Turbopack doesn't do any regex rewrite hacks, so this just worked
2026-07-06 12:01:09 +02:00
Niklas MischkulnigandGitHub c66662b932 test: Improve immutable static asset tests (#95349)
Cleanup and improve tests
2026-07-01 14:12:19 +02:00
Niklas MischkulnigandGitHub 84457f4e6c Turbopack: compute code hash per use cache function (#94234)
This computes the implementation hash of a given `use cache`:

- it includes the module containing the `use cache` function, plus all transitive imports of that module (including externals via NFT)
- what does it hash
    - for bundled code, it hashes the generated code (so including any AST transforms, inlined env vars, etc)
    - for NFTd files, it hashes the file content on disk
- So this is basically equivalent to hashing the generated JS chunks, except that it's scoped to only what the given actions module uses
- (so notably, if you have multiple use cache functions in a given file, then they will all have the same hash)

<br/>

- [x] Gate behind experimental flag
- [x] Only compute hash for `use cache` functions, not all server actions
- [ ] `final_read_hint` is a problem. Some chunk items are now codgened twice, so it recomputes the AST
- [x] disable for dev for now
- [ ] Measure perf impact


```jsonc
// .next/server/server-reference-manifest.json
{
  "node": {
    "806f4954cfbb75404a19d6d405065ed9059cc0cab2": {
      "workers": {
        "app/rsc/page": {
          "moduleId": "[project]/bench/app-router-server/.next-internal/server/app/rsc/page/actions.js { ACTIONS_MODULE0 => \"[project]/bench/app-router-server/app/rsc/logic.js [app-rsc] (ecmascript)\" } [app-rsc] (server actions loader, ecmascript)",
          "async": false,
          "exportedName": "$$RSC_SERVER_CACHE_0",
          "filename": "bench/app-router-server/app/rsc/logic.js",
          "codeHash": "413e394d9597b35df12828a6a7fd6363" // <------------
        }
      },
      "filename": "bench/app-router-server/app/rsc/logic.js",
      "exportedName": "$$RSC_SERVER_CACHE_0"
    }
  },
  "edge": {},
  "encryptionKey": "jOF2TbpNLjp2oOhl3VPBwGE7luodnei9clJPq/gaYQo="
}
```
2026-06-30 14:50:54 +02:00
Niklas MischkulnigandGitHub c99fef0032 [test] Unskip more Turbopack NFT unit tests (#95297)
These were already passing
2026-06-30 14:17:18 +02:00
Niklas MischkulnigandGitHub 26ba36077e Turbopack: constant evaluate x in y (#95286)
Prerequisite for https://github.com/vercel/next.js/pull/95233

Constant evaluation of
```js
if (!('NODE_ENV' in process.env)) {
  console.log('existing')
}
console.log('NODE_ENV' in process.env)
```
-> 
```js
if ("TURBOPACK compile-time falsy", 0) //TURBOPACK unreachable
;
console.log(("TURBOPACK compile-time value", true));
```
2026-06-30 11:04:56 +02:00
Niklas MischkulnigandGitHub 8a027d78eb Improve typing of decodeReply (#95263)
The types were unnecessarily specific (it doesn't always return a `T[]`)
2026-06-29 10:56:40 +02:00
Niklas MischkulnigandGitHub f509282984 Turbopack: make hash_xxh3_hash128 return u128 (#95232)
We already switched to 128 bit hashes for many operations, these were
still using 64 bit hashes.

- make `hash_xxh3_hash128` return `u128`, just like `hash_xxh3_hash64`
returns a `u64`
- Make `Code::source_code_hash` return a u128
2026-06-28 12:09:33 +02:00
Niklas MischkulnigandGitHub f66c8a6a78 [otel] Correctly set error code attributes for App API routes (#94979)
**View diff without whitespace**

When using adapters, throwing a JS error from a App Route Handler didn't
set the OTEL status code correctly.
It was doing this:
```js
try {
	tracer.trace(() => {
		try {
			// handle...
		} finally {
			setOtel();
		}
	});
} catch(e){
	send500();
}
```
Which I now changed to
```js
	tracer.trace(() => {
		try {
			// handle...
		} catch(e){
			send500();
		} finally {
			setOtel();
		}
	});

```
2026-06-22 14:47:58 +02:00
Niklas MischkulnigandGitHub bbd0abe854 [test] Fix failing determinism test using adapter (#95051)
https://github.com/nextjs/adapter-vercel/pull/70 broke the test

Instead, read the test-only `__NEXT_SUPPORTS_IMMUTABLE_ASSETS` after
modifyConfig.
2026-06-22 13:21:19 +02:00
Niklas MischkulnigandGitHub 73c63ae564 [otel] Add more verbose-mode OTEL spans for App Router (#94894)
This adds two new spans:
- `AppRender.renderToNodeFizzStream`
- `AppRender.waitShellReady`


Using the example from https://github.com/switz/nextjs-tracing-repro




with NEXT_OTEL_VERBOSE:

<img width="1245" height="408" alt="Bildschirmfoto 2026-06-17 um 18 11
28"
src="https://github.com/user-attachments/assets/5bd92d99-fc25-4490-aa25-9f8d0caeaf75"
/>
2026-06-19 16:31:22 +02:00
2d1d5268fb Upgrade to swc 70 (#94814)
<!-- 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

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

### Signed commits

- This repository requires verified commit signatures on protected
branches.
- If this pull request is blocked for unsigned commits, re-sign the
commits and force-push the branch.
- A `Signed-off-by` line in the commit message is not enough.


## 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: Will Binns-Smith <[email protected]>
2026-06-18 17:31:43 -07:00
Niklas MischkulnigandGitHub beee190d8b Fix repoRoot for adapters (#94478)
`repoRoot` shouldn't be `outputFileTracingRoot`. The user can configure
that to arbitrary values, which shouldn't change the adapter output.

The adapter now uses `NextConfigComplete.repoRoot` instead of
`outputFileTracingRoot`.

Closes NEXT-4942
2026-06-18 16:56:19 +02:00
Niklas MischkulnigandGitHub 3ba311dd13 Turbopack: fix tracing of [email protected] (#94845)
The logic is slightly less brittle now.
It broke because of this rename in v0.35:
```
@img/sharp-darwin-arm64/lib/sharp-darwin-arm64.node
->
@img/sharp-darwin-arm64/lib/sharp-darwin-arm64-0.35.1.node
```
2026-06-17 12:00:35 +02:00
Niklas MischkulnigandGitHub 8b24a83d29 Turbopack: don't run NFT for output:export or Edge (#94862)
- For `output: export`, there is no server (only SSG). So no need for
NFT
- For Edge, there are no files. So no need for NFT
2026-06-17 09:47:54 +02:00
Niklas MischkulnigandGitHub 9b8a7a1055 Turbopack: improve issue printing colors (#94858)
1. Align the code highlight marker color with the issue severity
2. Make the issue title colored
3. Prefix issues with `Warning` or `Error`


<img width="1383" height="862" alt="Bildschirmfoto 2026-06-16 um 18 59
03"
src="https://github.com/user-attachments/assets/f98c606d-4ea8-40c2-836d-e395f1df904c"
/>


<img width="1039" height="450" alt="Bildschirmfoto 2026-06-16 um 19 03
39"
src="https://github.com/user-attachments/assets/2747f914-0587-4178-a87d-344f24715c96"
/>



<details>
<summary>Old</summary>

<img width="1267" height="745" alt="Bildschirmfoto 2026-06-16 um 17 04
35"
src="https://github.com/user-attachments/assets/837739ff-82f7-4ea2-8767-ca7d866a8570"
/>

</details>
2026-06-16 21:29:37 +02:00
Niklas MischkulnigandGitHub fc05e6cbac Turbopack: improve NFT warning message (#94854)
<img width="1382" height="476" alt="Bildschirmfoto 2026-06-16 um 18 11
15"
src="https://github.com/user-attachments/assets/f0ac053a-92fc-4b72-aef7-18f02fd17a82"
/>
2026-06-16 19:59:28 +02:00
Niklas MischkulnigandGitHub 40296fe53f Fix remaining OTEL issues in adapter (#94817)
**View diff without whitespace**

1. RSC requests weren't properly handled
2. The mismatch on getServerSideProps is actually fine (depends on
whatever invokes the handler)
2026-06-16 18:37:55 +02:00
Niklas MischkulnigandGitHub 37e9d09966 Properly set response-based OTEL attributes with adapters (#94603)
**Ignore whitespace changes when viewing the diff**

This fixes some of the failures (particularly the ones where a 500
returned from an App API route showed up as status:200 in OTEL).
But the newly added tests have more failures that I skipped for now

1. Missing `setStatus` call
2. Attribute handling was too early, before `sendResponse` was called:



https://github.com/vercel/next.js/blob/6f4d94ac889db3d23a77847ec4f3a9dadf9dd775/packages/next/src/build/templates/app-route.ts#L289-L296
```js
  return routeModule.handle(nextReq, context).finally(() => { // <-- handle() returns the response object from the user code
        if (!span) return
        span.setAttributes({
          'http.status_code': res.statusCode,          // <---------- this is using some default response object, not what handle() returned
          'next.rsc': false,
        })
```
2026-06-16 13:47:47 +02:00
Niklas MischkulnigandGitHub ff865573ba Turbopack: content hash polyfill sourcemap file (#94548)
The sourcemap file of the polyfill chunk wasn't actually content hashed.
it just used the name of the corresponding JS chunk.
It was still emitted into `_next/static/immutable`. So it wasn't
actually immutable.

Now, it's content hashed (and this also removed the ad-hoc sourcemap
construction from app.rs and instead uses the usual pattern that all
other chunks use to reference their corresponding sourcemap chunks).


We didn't catch this because it only happens with
`nextConfig.productionBrowserSourceMaps: true` which isn't the default.
The test now covers this as well
2026-06-08 12:00:31 +00:00
Niklas MischkulnigandGitHub f5718d2c44 Turbopack: refactor into get_next_client_transforms_rules (#94487)
Straight up moving that `.extend()` into the function that produced the
vector a few lines before.
2026-06-08 10:07:47 +02:00
Niklas MischkulnigandGitHub 74bb0d9a6d Turbopack: fixup cache handler tracing (#94477)
https://github.com/vercel/next.js/pull/94197 had a bug in the Turbopack
case, where it didn't properly trace all necessary files referenced from
`cacheHandler` and `cacheHandlers`.

If you imported `lodash` in the cache handler, then
- `node_modules/.pnpm/[email protected].1/node_modules/lodash/lodash.js` was
correctly traced
but missing were
- `node_modules/.pnpm/[email protected].1/node_modules/lodash/package.json`
and
- `node_modules/lodash` (the symlink)

The problem was that it wasn't including affecting sources of these
entrypoints, because it was treating those entrypoints as bundled:

```
SingleModuleGraph::new_inner(
        entries: Vec<ChunkGroupEntry>,
        visited_modules: &FxIndexMap<ResolvedVc<Box<dyn Module>>, GraphNodeIndex>,
        include_traced: bool,
        include_binding_usage: bool,
        entries_are_traced: bool, // <------ problematic
    ) -> Result<Vc<Self>>
```

should really have been 

```
SingleModuleGraph::new_inner(
        entries: &GraphEntries, // contains Vec<ChunkGroupEntry> and traced_modules: Vec<Modules
        visited_modules: &FxIndexMap<ResolvedVc<Box<dyn Module>>, GraphNodeIndex>,
        include_traced: bool,
        include_binding_usage: bool,
    ) -> Result<Vc<Self>> {
```
because the single `entries_are_traced: bool` can be different per
entry.
2026-06-05 20:50:32 +02:00
Niklas MischkulnigandGitHub 87ce7a7a70 Turbopack: refactor to use get_ecma_transform_rule (#94485)
Use a util function instead
2026-06-05 17:54:53 +00:00
Niklas MischkulnigandGitHub 4162a56b41 Turbopack: refactor ServerActionManifestAsset to be lazy (#94377)
Previously, `AppEndpoint::output` computed the manifest content eagerly.
This change moves it to the emit phase.
2026-06-05 09:23:22 +00:00
d70b854294 Turbopack: fix pages index normalization for --debug-build-paths (#94341)
Recreation of https://github.com/vercel/next.js/pull/90314

---

## Summary
- Fix `--debug-build-paths` pages normalization in Turbopack so
`pages/<name>/index.tsx` maps to `/<name>` (matching JS
`getPageFromPath()` behavior).
- Handle index page edge case: `/index.tsx -> /`.
- Keep regression coverage in
`test/production/debug-build-path/debug-build-paths.test.ts` with a
generic fixture `pages/with-index/index.tsx`.

## Current Behavior Reference
- CI run (before this fix) that failed as expected for this bug:
-
https://github.com/vercel/next.js/actions/runs/22266469801/job/64413677099?pr=90314#step:35:216

## Root Cause
Rust-side debug-build-path normalization removed file extensions but did
not remove `/index`, producing route keys like `/with-index/index` while
pages route keys are `/with-index`. That mismatch filtered out the page
and caused `PageNotFoundError` during page-data collection.

---------

Co-authored-by: devjiwonchoi <[email protected]>
2026-06-03 09:56:04 +02:00
Niklas MischkulnigandGitHub d4db8c9f21 Turbopack: support turbopackIgnore on more traced calls (#94361)
This already worked:
```js
fs.readFileSync(/*turbopackIgnore: true*/ x)
```
but this didn't:
```js
fs.readdirSync(/*turbopackIgnore: true*/ x)
```
2026-06-02 20:11:16 +00:00
Niklas MischkulnigandGitHub ad175bb874 [tests] Use snapshots in debug-build-paths (#94352)
Make sure that we don't accidentally match too many pages
2026-06-02 21:46:07 +02:00
Niklas MischkulnigandGitHub 0e6f52e99b Turbopack: fix bundle-analyzer for NFT change (#93363)
We have no testing infrastructure, unfortunately

<img width="2254" height="1260" alt="Bildschirmfoto 2026-05-28 um 20 29
58"
src="https://github.com/user-attachments/assets/a9f1b646-994d-4417-98d7-160ce5249032"
/>
2026-06-02 18:24:38 +02:00
62467ee5cc fix(instrumentation): await instrumentation in RouteModule.prepare (#94306)
Closes #93994
Unfortunately deploy tests can't pass on external PRs like #93994
currently due to missing secrets

----


The per-request call to ensureInstrumentationRegistered() inside
RouteModule.prepare was missing an await, so when an adapter dispatches
the compiled app-route template's handler without going through
BaseServer.handleRequest (where prepareImpl awaits it via
runInstrumentationHookIfAvailable), a cold-start request could begin
executing the userland route handler before
instrumentation.ts#register() resolved. The other two call sites
(next-server.ts and web/adapter.ts) already await; this aligns the
third.

This only caused a problem with adapters

---------

Co-authored-by: Maurits Misana <[email protected]>
Co-authored-by: Tim Neutkens <[email protected]>
2026-06-01 17:19:46 +02:00
Niklas MischkulnigandGitHub 2ae01a843e Turbopack: show codeframe when tracing too much (#94207)
Finally, we can show a codeframe
<img width="1204" height="774" alt="Bildschirmfoto 2026-05-28 um 21 16
35"
src="https://github.com/user-attachments/assets/a70c1fce-8a86-472a-9904-28f181d32385"
/>
2026-06-01 16:14:59 +02:00
Niklas MischkulnigandGitHub 87ee4fe431 Turbopack: refactor NFT to add Endpoint.traced_files (#94224)
Refactor the module-graph bit of NFT so that we can provide
`Endpoint.traced_files()` which is needed for the bundle analyzer

There should be no logic change whatsoever
2026-06-01 14:57:41 +02:00
Niklas MischkulnigandGitHub c3e35b5738 Turbopack: cleanup ModuleHotReferenceAssetReference (#94206)
No need for a separate `pub async fn resolve()`, just call
`ModuleReference.resolve_reference` directly
2026-05-29 08:33:20 +00:00
Niklas MischkulnigandGitHub 5ee7005200 Turbopack: use module graph for NFT (#92901)
- [x] skip traced edges properly in all graph traversals
- [x] iter_nodes and enumerate_nodes include the traced modules
    - [x] Don't propagate is_self_async inside of traced references as a perf optimization
- [x] fix performance
- [x] validate that NFT JSON files are identical
- [x] ~~validate/adjust bundle analyzer output~~ will be in followup
- [x] audit `fn chunking_type()` changes

Benchmark:
```
* ced85b3108 - (2 weeks ago) refactor - Niklas Mischkulnig (HEAD -> mischnic/nft-module-graph, origin/mischnic/nft-module-graph)

TURBOPACK_PERSISTENT_CACHE=0 NEXT_TURBOPACK_TRACING= pnpm next build   334.96s user 44.57s system 788% cpu 48.152 total
TURBOPACK_PERSISTENT_CACHE=0 NEXT_TURBOPACK_TRACING= pnpm next build   343.39s user 42.61s system 809% cpu 47.659 total

* 5edf48238f - (77 minutes ago) v16.3.0-canary.32 - next-js-bot[bot] (HEAD, tag: v16.3.0-canary.32)

TURBOPACK_PERSISTENT_CACHE=0 NEXT_TURBOPACK_TRACING= pnpm next build   333.42s user 43.57s system 712% cpu 52.877 total
TURBOPACK_PERSISTENT_CACHE=0 NEXT_TURBOPACK_TRACING= pnpm next build   332.95s user 43.15s system 791% cpu 47.515 total
TURBOPACK_PERSISTENT_CACHE=0 NEXT_TURBOPACK_TRACING= pnpm next build   337.59s user 41.28s system 771% cpu 49.117 total
TURBOPACK_PERSISTENT_CACHE=0 NEXT_TURBOPACK_TRACING= pnpm next build   335.25s user 45.53s system 718% cpu 52.975 total
```

<details>
<summary>Previous benchmarks</summary>

```
52212418699f362904d64c08e544d4994e8d27fa mischnic/nft-module-graph

pnpm next build   371.41s user 66.39s system 737% cpu 59.353 total
pnpm next build   380.13s user 59.62s system 751% cpu 58.548 total
pnpm next build   374.25s user 60.55s system 761% cpu 57.102 total

8e4cfc5062 canary

pnpm next build   370.77s user 53.89s system 762% cpu 55.725 total
pnpm next build   383.16s user 55.61s system 744% cpu 58.921 total
pnpm next build   382.34s user 53.51s system 757% cpu 57.512 total
pnpm next build   381.15s user 54.50s system 751% cpu 57.943 total
```


```
b0d5411a79 mischnic/nft-module-graph
pnpm next build --experimental-build-mode=compil  368.75s user 62.05s system 749% cpu 57.445 total
pnpm next build --experimental-build-mode=compil  368.95s user 58.42s system 763% cpu 56.004 total

0e3ad2768bd3b036e96f66e4b770a16bb0b38705 mischnic/nft-module-graph
pnpm next build --experimental-build-mode=compil  369.48s user 60.62s system 748% cpu 57.494 total
pnpm next build --experimental-build-mode=compil  374.89s user 52.27s system 730% cpu 58.449 total
pnpm next build --experimental-build-mode=compil  375.02s user 52.89s system 747% cpu 57.274 total

f37073e1d96f6d846cd333b93fccd1dd7bdc253e mischnic/speed-next-dynamic-map
pnpm next build --experimental-build-mode=compil  389.58s user 55.98s system 704% cpu 1:03.21 total

e599b11e2d6b09a92600cfca6d9b338ed1f7537d mischnic/fix-side-effect-edge-removal
pnpm next build --experimental-build-mode=compil  386.60s user 53.34s system 720% cpu 1:01.09 total

f68f70b044 canary
pnpm next build --experimental-build-mode=compil  387.46s user 53.72s system 738% cpu 59.716 total
pnpm next build --experimental-build-mode=compil  390.33s user 53.54s system 734% cpu 1:00.43 total
pnpm next build --experimental-build-mode=compil  385.33s user 56.55s system 722% cpu 1:01.18 total
pnpm next build --experimental-build-mode=compil  386.49s user 56.44s system 726% cpu 1:00.96 total
```



```
b1ed4553e6 origin/mischnic/nft-module-graph
pnpm next build --experimental-build-mode=compile  467.28s user 75.24s system 791% cpu 1:08.56 total
pnpm next build --experimental-build-mode=compile  465.00s user 76.80s system 831% cpu 1:05.20 total
pnpm next build --experimental-build-mode=compile  473.86s user 70.73s system 790% cpu 1:08.90 total

3cb77c844b canary
pnpm next build --experimental-build-mode=compile  367.91s user 58.06s system 726% cpu 58.672 total
pnpm next build --experimental-build-mode=compile  362.97s user 57.68s system 746% cpu 56.379 total
pnpm next build --experimental-build-mode=compile  364.59s user 57.01s system 724% cpu 58.167 total
```

</details>
2026-05-28 20:10:34 +02:00
Niklas MischkulnigandGitHub 4797acb82d Turbopack: fix instrumentationClientInject with type:module (#94184)
If the user's `package.json` contains, `type: module`, then the file
generated by Turbopack at `[project]/__next_instrumentation_client.js`
would get treated as ESM. But it always contains CJS, causing
```
Uncaught (in promise) ReferenceError: module is not defined
    at module evaluation (__next_instrumentation_client.js:3:1)
```
2026-05-28 10:28:00 +02:00
Niklas MischkulnigandGitHub d6d392a492 Upgrade ast-grep (#94150)
It wasn't properly analyzing async closures:
https://github.com/vercel/next.js/blob/67d5f9615a6abb14dc2a06737c2810e2c6b6f7b0/.config/ast-grep/rule-tests/no-map-async-cell-test.yml#L34
2026-05-27 12:55:05 +02:00
Niklas MischkulnigandGitHub 55b2d3c744 Upgrade rustc to nightly-2026-05-15 (#94021) 2026-05-21 20:26:11 +02:00
Niklas MischkulnigandGitHub 6e894d0511 Turbopack: respect the module-sync export condition (#93970)
I set it to `::Unknown` because we the runtime may or may not support
module-sync. So let's just trace both for now



There is one problem though:


https://nodejs.org/docs/latest-v26.x/api/packages.html#conditional-exports
> "module-sync" - matches no matter the package is loaded via import,
import() or require(). The format is expected to be ES modules that does
not contain top-level await in its module graph - if it does,
ERR_REQUIRE_ASYNC_MODULE will be thrown when the module is require()-ed.

So we have multiple options:
1. We definitely want to respect module-sync for tracing. We don't
really have to throw ERR_REQUIRE_ASYNC_MODULE here, Node.js will do it
at runtime anyway.
2. ~~What about bundling? Either~~
- ~~Respect module-sync always, but don't throw
ERR_REQUIRE_ASYNC_MODULE.~~
- ~~Respect module-sync always, and do throw a build error the module
requires TLA. This would require a separate validation pass though.~~
   - I'm not enabling it for bundling for now
2026-05-20 21:29:22 +02:00
Niklas MischkulnigandGitHub d13adce31f Fix Yarn berry tests (#93962)
4.15 made [npmMinimalAgeGate: 1d the
default](https://github.com/yarnpkg/berry/pull/7135)

1. Pin yarn version to prevent random breakages in the future
2. Add trusted packages to ignore npmMinimalAgeGate for them

https://github.com/yarnpkg/berry/releases/tag/%40yarnpkg%2Fcli%2F4.15.0
2026-05-20 10:24:02 +00:00
Niklas MischkulnigandGitHub 797d0060df docs: instrumentationClientInject (#93913)
Add docs for https://github.com/vercel/next.js/pull/93785
2026-05-20 11:48:50 +02:00
Niklas MischkulnigandGitHub 40d7843df7 Turbopack: fix subpath imports pointing to external packages (#93308)
Closes https://github.com/vercel/next.js/issues/93295
Closes #93914

https://nodejs.org/api/packages.html#subpath-exports:

> All target paths in the
["exports"](https://nodejs.org/api/packages.html#exports) map (the
values associated with export keys) must be relative URL strings
starting with `./`

but

>Unlike the "exports" field, the "imports" field permits mapping to
external packages.
>The resolution rules for the imports field are otherwise analogous to
the exports field.
2026-05-20 10:08:25 +02:00
Niklas MischkulnigandGitHub 944e45484e Add nextConfig.instrumentationClientInject (#93785)
This allows injecting client bootstrap code using only next.config.js
(without writing to any user source files).
2026-05-19 17:58:36 +02:00
Niklas MischkulnigandGitHub f46db1c4a6 Pass projectDir to adapter modifyConfig (#93916)
Adapters implementing `modifyConfig` may need to know the absolute
project directory to perform path resolution or apply directory-specific
configuration logic. Without this value, adapters had no reliable way to
determine where the application lives on disk.

onBuildComplete already received the directory as a parameter.
2026-05-18 13:35:58 +00:00
Niklas MischkulnigandGitHub 9a48c22c17 Turbopack: expose hashes of source files to adapters (#93539)
- [x] fix tests
- [ ] add experimental flag and only enable in adapter? or is this cheap
enough to just always do?
- [x] disable for webpack




Closes PACK-6541

For https://github.com/nextjs/adapter-vercel/pull/24
Newer version of https://github.com/vercel/next.js/pull/89534

- Add a hashes mapping to the NFT file
- Forward that information to the adapter via `assetsHashes` for
functions


Basically zero-cost:
```
commit ad728b15a6431a6372eea3d3d766b328569811b4 (HEAD -> mischnic/server-paths-manifest-2, origin/mischnic/server-paths-manifest-2)
pnpm next build   351.22s user, 51.55s system, 811% cpu, 49.654 total
pnpm next build   354.52s user, 53.39s system, 837% cpu, 48.706 total
pnpm next build   344.02s user, 63.62s system, 749% cpu, 54.368 total
pnpm next build   353.74s user, 54.25s system, 833% cpu, 48.970 total

commit 04294cb47a (origin/canary, origin/HEAD)
pnpm next build   344.24s user, 53.88s system, 798% cpu, 49.845 total
pnpm next build   340.89s user, 52.40s system, 784% cpu, 50.138 total
pnpm next build   347.26s user, 51.91s system, 802% cpu, 49.741 total
pnpm next build   347.04s user, 52.65s system, 803% cpu, 49.764 total
```
2026-05-11 22:27:11 +02:00
Niklas MischkulnigandGitHub 554b7fe3b0 Turbopack: don't generate next-server.js.nft.json with adapters (#93684)
Adapters don't read these files.

Also added a snapshot test similar to the existing ones to not regress
on function size
2026-05-11 09:13:27 +00:00
ead8013f88 Turbopack: more strict vergen setup (#93541)
Co-authored-by: Tobias Koppers <[email protected]>
Co-authored-by: Sebastian Sebbie Silbermann <[email protected]>
2026-05-07 08:50:02 +00:00
Niklas MischkulnigandGitHub 5611e1234c Turbopack: really fix MAX_INLINE_LEN (#93531)
1. https://github.com/vercel/next.js/issues/93516 was first opened.
Everything worked. It introduced one more `< MAX_INLINE_LEN` comparison
2. https://github.com/vercel/next.js/issues/93524 fixed an off-by-one
error (which was fine all long as all of them were consistently off by
one)
3. Then https://github.com/vercel/next.js/issues/93516 merged without
rebasing and on canary, the one added callsite was now inconsistent with
the rest. So CI failed on canary

This caused a lot of test failures:
```
➜  next.js git:(canary) UPDATE=1 cargo nextest run -p turbopack-tests -E 'test(test_tests__execution__webpack__scope_hoisting__esModule__input__index_js)' --no-capture
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.55s
────────────
 Nextest run ID a86cddd0-85b8-4f6c-b550-0e5870a9daf1 with nextest profile: default
    Starting 1 test across 3 binaries (305 tests skipped)
       START [         ] (1/1) turbopack-tests::execution test_tests__execution__webpack__scope_hoisting__esModule__input__index_js

running 1 test
Input: next.js/turbopack/crates/turbopack-tests/tests/execution/webpack/scope-hoisting/esModule/input/index.js
updated contents of turbopack/crates/turbopack-tests/tests/execution/webpack/scope-hoisting/esModule/issues/Code generation for chunk item errored-803648.txt

thread 'test_tests__execution__webpack__scope_hoisting__esModule__input__index_js' (46528180) panicked at turbopack/crates/turbopack-tests/tests/execution.rs:105:9:
Failed with error(s) in the following test(s):

"should have the __esModule flag":
Error: An error occurred while generating the chunk item [project]/turbopack/crates/turbopack-tests/tests/execution/webpack/scope-hoisting/esModule/input/module.js [test] (ecmascript)

Caused by:
- Processing [project]/turbopack/crates/turbopack-tests/tests/execution/webpack/scope-hoisting/esModule/input/module.js [test] (ecmascript)
- Expected to find a local export for default with ctxt #4 in {"default": ("__TURBOPACK__default__export__", #0)}

Debug info:
- An error occurred while generating the chunk item [project]/turbopack/crates/turbopack-tests/tests/execution/webpack/scope-hoisting/esModule/input/module.js [test] (ecmascript)
- Execution of <MergedEcmascriptModule as EcmascriptChunkPlaceable>::chunk_item_content failed
- Execution of *EcmascriptChunkItemContent::new failed
- Execution of EcmascriptModuleContent::new_merged failed
- Processing [project]/turbopack/crates/turbopack-tests/tests/execution/webpack/scope-hoisting/esModule/input/module.js [test] (ecmascript)
- Expected to find a local export for default with ctxt #4 in {"default": ("__TURBOPACK__default__export__", #0)}
```
2026-05-06 10:05:19 +00:00
Niklas MischkulnigandGitHub 3d4df34575 Turbopack: make rcstr! macro expansion const (#93516)
Brought to you by
```
destructor of `std::option::Option<turbo_rcstr::RcStr>` cannot be evaluated at compile-time
```
and
```
cannot perform conditionally-const deref coercion on `std::mem::ManuallyDrop<std::option::Option<RcStr>>` in constants
```
2026-05-06 09:24:37 +02:00
Niklas MischkulnigandGitHub 4976adbbf4 Turbopack: fix import_usage for functions behind member expressions (#93504)
Manifested as `ReferenceError: foo is not defined` where `foo` is an
import

A regression from https://github.com/vercel/next.js/pull/92891
2026-05-05 18:18:46 +00:00
Niklas MischkulnigandGitHub 07f76411b0 Include deployment id in cacheHandlers keys (#93453)
How was this ever working for dev? In that case, `buildId =
"development"` and so it always uses the same cache key
2026-05-04 18:26:07 +02:00
Niklas MischkulnigandGitHub 8f77276c71 Upgrade to swc 65 (#93325)
https://github.com/swc-project/swc/compare/a0716503cc2b359ff6620d0ae5c0e8afaa18c185...b815eb24190dc54443486ccee161a419e247826b

Closes https://github.com/vercel/next.js/issues/93353
2026-05-04 10:02:50 +02:00
Niklas MischkulnigandGitHub 6eb0126dc0 Turbopack: delete unused turbo-static crate (#93324)
Added in https://github.com/vercel/turborepo/pull/8037

Nobody uses this, and it's also the only crate that uses the lsp-server
dependency.
2026-04-29 14:18:50 +00:00
Niklas MischkulnigandGitHub bed584b3d4 Turbopack: remove ModuleResolveResultItem::OutputAsset (#93349)
It never made sense to have module references that point to an output
asset, and the `ChunkingType` value on those made even less sense. We
had already migrated almost everything off anyway
2026-04-29 13:47:24 +02:00
Niklas MischkulnigandGitHub 5eec78a13b Turbopack: remove unused module references (#93335)
- SingleModuleReference is dead code, never actually called
- SingleOutputAssetReference was created, but never actually did anything because of the ChunkingType being None
2026-04-29 12:43:07 +02:00
Niklas MischkulnigandGitHub 470cf12ae4 Turbopack: pull in updated vercel/nft tests (#93321)
From
https://github.com/vercel/nft/commit/baf9df627e30f3e3c4199eeda128a527c715fffc

Still need to eventually look into actually enabling all of these
2026-04-28 21:22:46 +00:00
Niklas MischkulnigandGitHub 8384791ee4 Turbopack: also add edge count to trace (#93314)
<!-- 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

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

### Signed commits

- This repository requires verified commit signatures on protected
branches.
- If this pull request is blocked for unsigned commits, re-sign the
commits and force-push the branch.
- A `Signed-off-by` line in the commit message is not enough.


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

-->
2026-04-28 21:17:07 +00:00
Niklas MischkulnigandGitHub 99bfe96725 Turbopack: add failing test for cross-module side-effect inference (#93323)
Currently not implemented, but maybe in the future
2026-04-28 21:05:39 +00:00
Niklas MischkulnigandGitHub 28c9eefab2 Turbopack: iter_reachable_modules (#93315)
Add `iter_reachable_modules` and `iter_reachable_nodes`. They actually respect unused references
2026-04-28 23:03:10 +02:00
Niklas MischkulnigandGitHub 6d2cb42fde ci: Fix caching of test-cargo-unit (#93327)
Previously, it only used the rust files as the cache key via `rust-fingerprint`.
So changing fixtures didn't invalidate the turborepo run.
2026-04-28 22:49:41 +02:00
Niklas MischkulnigandGitHub b694eeb590 Turbopack: only compute module ids for included modules (#93276)
Currently doesn't have a measureable performance impact.

Previously we assigned module ids for all nodes in the graph, even the subgraphs we detect as unused. They weren't chunked already, but the codegen that references those wasn't gracefully handling `.chunk_item_id(m)` failing (where `m` is a unused skipped module)

So `.iter_nodes()` should basically be deprecated. It doesn't respect `removed_unused_imports` and the side-effect-free inference. 
And this would get much much worse once NFT is on the module graph, because then there are way more modules that should be skipped via the same mechanism

This manifested as the following error after switching from `.iter_nodes` to `.traverse_edges_unordered` in global_module_ids.rs
```
Debug info:
- An error occurred while generating the chunk item [project]/node_modules/.pnpm/next@file+..+next.js+packages+next_@[email protected].0_@[email protected]_@playwri_9a8ea08672cbf59c2720abbb0c8879be/node_modules/next/dist/esm/server/stream-utils/node-web-streams-helper.js [app-rsc] (ecmascript)
- Execution of <MergedEcmascriptModule as EcmascriptChunkPlaceable>::chunk_item_content failed
- Execution of *EcmascriptChunkItemContent::new failed
- Execution of EcmascriptModuleContent::new_merged failed
- ModuleId not found for ident: [project]/node_modules/.pnpm/next@file+..+next.js+packages+next_@[email protected].0_@[email protected]_@playwri_9a8ea08672cbf59c2720abbb0c8879be/node_modules/next/dist/esm/shared/lib/hash.js [app-rsc] (ecmascript)

```
2026-04-28 22:21:36 +02:00
Niklas MischkulnigandGitHub 7df1a40bb7 Turbopack: cheaper check in map_next_dynamic (#93283)
Currently doesn't have a measureable performance impact.

Attempt the cheap downcast first and only do the ident reading and
comparison in the uncommon case
2026-04-28 13:00:04 +02:00
Niklas MischkulnigandGitHub eb76391829 Turbopack: compute exports without full analysis (#92823)
We don't actually need the full analysis to compute exports. This can
break some task cycles, and might theoretically improve task latency.

The CPU time appears to be marginally higher (but not statistically
significant), but no impact on overall build time:
```
* c4fdcc2651 - (14 hours ago) compute exports before final_read_hint() - Niklas Mischkulnig (origin/mischnic/get-exports-without-analyze, mischnic/get-exports-without-analyze)

pnpm next build --experimental-build-mode=compile  378.10s user 58.28s system 760% cpu 57.411 total
pnpm next build --experimental-build-mode=compile  383.64s user 60.32s system 738% cpu 1:00.10 total
pnpm next build --experimental-build-mode=compile  378.70s user 55.65s system 718% cpu 1:00.41 total

* 8ddc1cdbdd - (38 minutes ago) Use OIDC for CodSpeed (#93059) - Niklas Mischkulnig (origin/canary, origin/HEAD, canary)

pnpm next build --experimental-build-mode=compile  376.95s user 58.30s system 755% cpu 57.597 total
pnpm next build --experimental-build-mode=compile  375.85s user 61.75s system 738% cpu 59.230 total
pnpm next build --experimental-build-mode=compile  377.75s user 63.00s system 729% cpu 1:00.39 total
```
2026-04-28 11:52:08 +02:00
Niklas MischkulnigandGitHub d170370a3a Turbopack: move get_inner_asset into ecmascript module (#93191)
`resolve_origin.get_inner_asset` showed up in Luke's statistics at a
very high place.
But in reality, there are only 1-3 modules per page that have any inner
assets (the templates, and the edge wrapper modules).
`resolve_origin.get_inner_asset` is in the hottest hot path (resolving
references), so let's simply move this logic into the
EcmascriptModuleAsset itself.

Behavioral differences to before:
- only works with static ESM `import`s, dynamic `import()`, `require`,
`require.resolve`. But these are the only places that currently use it
anyway.

```
0d9738112f mischnic/remove-get-inner-asset
pnpm next build --experimental-build-mode=compile  353.40s user 52.96s system 748% cpu 54.265 total
pnpm next build --experimental-build-mode=compile  349.42s user 53.84s system 744% cpu 54.198 total
pnpm next build --experimental-build-mode=compile  352.42s user 54.46s system 741% cpu 54.874 total

3cb77c844b canary
pnpm next build --experimental-build-mode=compile  367.91s user 58.06s system 726% cpu 58.672 total
pnpm next build --experimental-build-mode=compile  362.97s user 57.68s system 746% cpu 56.379 total
pnpm next build --experimental-build-mode=compile  364.59s user 57.01s system 724% cpu 58.167 total
```
2026-04-24 22:07:06 +02:00
Niklas MischkulnigandGitHub 3cb77c844b Turbopack: unify ModuleGraph constructors (#93203)
We have options and variable length lists. Why do we need a separate
function for every combination?
2026-04-24 18:42:04 +02:00
Niklas MischkulnigandGitHub cc0575745a Turbopack: move import_usage computation into ImportMap (#92891)
I'm moving all of the export-related logic into `EvalContext` (and thus
`ImportMap`) so that `VarGraph` is only needed for computing the
references, and not the exports.
2026-04-24 13:54:50 +02:00
Niklas MischkulnigandGitHub 8ddc1cdbdd Use OIDC for CodSpeed (#93059)
https://codspeed.io/docs/integrations/ci/github-actions/configuration#oidc-recommended
2026-04-21 10:07:56 +02:00
Niklas MischkulnigandGitHub a226531900 Support type cast expressions in page static info extractor (#92837)
So that
```ts
export const runtime = "node" as const
export const runtime = "node" as string
export const runtime = "node" satisfies string // was already working
```
works
2026-04-16 15:52:41 +02:00
Niklas MischkulnigandGitHub 26cfeb8531 Allow overriding outputHashSalt in modifyConfig (#92856) 2026-04-16 12:43:26 +02:00
Niklas MischkulnigandGitHub bf4de72c7d Turbopack: move assignment_scopes computation into ImportMap (#92835)
I'm moving all of the export-related logic into `EvalContext` (and thus `ImportMap`) so that `VarGraph` is only needed for computing the references, and not the exports.

The change in the snapshots is 
```diff
-*anonymous function 170* (const after eval) = (...) => [file]
+*anonymous function 170* = (...) => [file]
```
which is fine, since computing the "is reassigned" data for something that isn't actually a variable was non-sensical anyway.
2026-04-15 23:35:03 +02:00
Niklas MischkulnigandGitHub 69b9c4bc41 Turbopack: analyzer improvement followups (#92834)
- defer computing the `EsmAssetReference` issue source from the `Span`. means that we have to pass less arguments around as well
- make `mangle("default export")` a "constant" and use that everywhere instead

Some snapshots changed, because the test runner had `source: None`, so now there are some duplicate module references in there because the new always-set `span` field forces it to be a new entry in the `data.references` hashmap.
2026-04-15 22:23:13 +02:00
Niklas MischkulnigandGitHub 45e5ad7641 Turbopack: remove StarImportAnalyzer (#92830)
There is actually no reason to compute `full_star_imports` before the `visit_with(&mut analyzer)`: it's only used later on by references/mod.rs which calls `should_import_all`.
So we can just do it in the same traversal
2026-04-15 22:20:35 +02:00
Niklas MischkulnigandGitHub de62a9660b Turbopack: refactor export analysis (#92781)
Remove `ModuleReferencesVisitor` and move everything into the `ImportMap` `Analyzer`
2026-04-15 18:22:17 +02:00
Niklas MischkulnigandGitHub 3f17705979 Turbopack: properly set NODE_ENV for SWC plugins (#92579)
### What?

Closes https://github.com/vercel/next.js/pull/92650
Closes https://github.com/vercel/next.js/issues/92547

When Turbopack runs SWC transform plugins, it passes a `TransformPluginMetadataContext` that includes the current `NODE_ENV`. Previously this value was hardcoded to `"development"` regardless of the actual build mode, causing SWC plugins to misbehave during production builds.

### Why?

`SwcPluginMetadataContext` is used by SWC plugins (e.g. `babel-plugin-styled-components`, `@swc/plugin-emotion`) to conditionally produce development vs. production output — for instance, injecting display names and data attributes only in development. With `NODE_ENV` always set to `"development"`, plugins could never produce their optimised production output, resulting in larger bundles and missing minification in `next build`.

Fixes https://github.com/vercel/next.js/issues/92547

### How?

`NODE_ENV` is now derived from the `process.env.NODE_ENV` compile-time define that is already part of `CompileTimeInfo` (the same source of truth used for dead-code elimination). The resolution happens in `EcmascriptModuleAsset::parse()` via a new shared helper `node_env_from_compile_time_info()` in `parse.rs`, and the value is stored on `TransformContext` so every `CustomTransformer` implementation can read it from `ctx.node_env` without needing access to the broader compilation context.

Key design decisions:

- **`TransformContext`** is the right place: it is the per-file context passed to every `CustomTransformer::transform()` call, so storing `node_env` there follows the existing pattern and avoids coupling the plugin struct to the build mode.
- **Webpack analysis path**: `compile_time_info` is now threaded through `webpack_runtime()`, `module_references()`, and the webpack reference structs (`WebpackModuleAsset`, `WebpackChunkAssetReference`, `WebpackEntryAssetReference`, `WebpackRuntimeAssetReference`) so that webpack-bundled files with SWC plugin transforms also receive the correct `NODE_ENV`.
- **`segment_config.rs`**: passes a placeholder but includes a comment explaining it is irrelevant since `EcmascriptInputTransforms::empty()` means no transforms run.

<!-- NEXT_JS_LLM_PR -->
2026-04-15 14:55:20 +02:00
Niklas MischkulnigandGitHub 2e916555d4 Turbopack: shorter error for ChunkGroupInfo::get_index_of (#92814) 2026-04-15 14:33:30 +02:00
Niklas MischkulnigandGitHub 56e5acc099 webpack: fix swcPlugins with relative paths (#92770)
Webpack didn't correctly load relative paths for `swcPlugins`.

https://github.com/vercel/next.js/pull/92579 will add a test
2026-04-15 12:04:48 +02:00
Niklas MischkulnigandGitHub b6cf70eba0 Turbopack: refactor ESM codegen generation (#92777)
Move more logic out of the `ModuleReferencesVisitor`, so that we can remove it at some point.
2026-04-15 11:44:11 +02:00
Niklas MischkulnigandGitHub 7f3cfffea7 Turbopack: remove webpack chunk detection (#92773)
To see if we have any tests at all for this...

Was added here: https://github.com/vercel/next.js/commit/b20f02830c03053bee650049830db065878cf6a1 `add special case for tracing webpack bundles` by @sokra 

We can add this back again with a better implementation if we end up needing this anyway

Looks like this was used to trace webpack chunks, particularly back from the time when we used to trace the output chunks.
2026-04-15 11:11:30 +02:00
Niklas MischkulnigandGitHub e309a6ef70 test: Add tests for client reference side effects (#92774)
Just adding some test coverage

- Turbopack: module are only evaluated when the given module is actually
rendered
- Webpack: all client component modules are evaluated when at least one
client reference renders
2026-04-14 13:09:46 +02:00
Niklas MischkulnigandGitHub cd1b55b01c Turbopack: properly remove unused TS enums with scope hoisting (#88205)
Needs https://github.com/swc-project/swc/pull/11777

https://github.com/swc-project/swc/pull/10560 added `Files.map_raw_pos` which can be used to translate BytePos before generating the sourcemap.

The same is also needed in `SourceMapper`, so that the `pos.is_pure()` in `emit_leading_comments` uses the decoded BytePos.

This came up in https://github.com/vercel/next.js/pull/88205 where my BytePos re-encoding mechanism caused `BytePos::PURE` to not codegen the pure comment anymore.

Closes https://github.com/vercel/next.js/issues/88009
Closes https://github.com/vercel/next.js/pull/90004
Closes PACK-6424
2026-04-13 11:47:05 +02:00