Unverified Commit a2b3c15e authored by Josh Story's avatar Josh Story Committed by GitHub

Avoid mutating config for default export paths (#99496)

## Summary

Static export currently installs an identity `exportPathMap` callback on
the resolved config when no callback is configured. Use the default path
map directly while preserving configured callbacks. This removes another
config mutation as part of immutable configuration support for adapters.

## Verification

- `pnpm test-start-webpack
test/production/fallback-export-error/index.test.ts` (4 passed, covering
default, valid custom, and invalid custom path maps)

<!-- NEXT_JS_LLM -->
parent 89816449
...@@ -397,13 +397,6 @@ async function exportAppImpl( ...@@ -397,13 +397,6 @@ async function exportAppImpl(
) )
} }
// Get the exportPathMap from the config file
if (typeof nextConfig.exportPathMap !== 'function') {
nextConfig.exportPathMap = async (defaultMap) => {
return defaultMap
}
}
const { const {
i18n, i18n,
images: { loader = 'default', unoptimized }, images: { loader = 'default', unoptimized },
...@@ -550,6 +543,10 @@ async function exportAppImpl( ...@@ -550,6 +543,10 @@ async function exportAppImpl(
const exportPathMap = await span const exportPathMap = await span
.traceChild('run-export-path-map') .traceChild('run-export-path-map')
.traceAsyncFn(async () => { .traceAsyncFn(async () => {
if (typeof nextConfig.exportPathMap !== 'function') {
return defaultPathMap
}
const exportMap = await nextConfig.exportPathMap(defaultPathMap, { const exportMap = await nextConfig.exportPathMap(defaultPathMap, {
dev: false, dev: false,
dir, dir,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment