Files
Hendrik LiebauandGitHub c4c3aee98f Fix --no-mangling for "use cache" functions (#78993)
When mangling is disabled with `next build --no-mangling`, the function
names of `"use cache"` functions are currently still mangled.

The reason is that those functions are transformed to inline function
expressions whose names are removed by the SWC minifier even if `mangle`
is `false`.

Original:

```js
'use cache'

export async function getCachedData() {
  return functionThatMightThrow()
}
```

Transformed by the Next.js compiler during `next dev`:

```js
export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "<id>", 0, async function getCachedData() {
  return functionThatMightThrow()
});
```

Transformed by the Next.js compiler during `next build`:

```js
export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "<id>", 0, async function () {
  return functionThatMightThrow()
});
```

By setting `keep_fnames` to `true` in SWC's `compress` options, we can
ensure that those function expression names are preserved when building
with `--no-mangling`, which is helpful when looking at error stacks or
traces.
2025-05-09 11:41:38 +00:00

12 lines
171 B
JavaScript

/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
experimental: {
useCache: true,
prerenderEarlyExit: false,
},
}
module.exports = nextConfig