(
phase: PHASE_TYPE,
dir: string,
{
customConfig,
rawConfig,
silent = true,
reportExperimentalFeatures,
reactProductionProfiling,
debugPrerender,
bundler,
}: LoadConfigOptions = {}
)
| 1541 | ): Promise<NextConfigComplete> |
| 1542 | |
| 1543 | export default async function loadConfig( |
| 1544 | phase: PHASE_TYPE, |
| 1545 | dir: string, |
| 1546 | { |
| 1547 | customConfig, |
| 1548 | rawConfig, |
| 1549 | silent = true, |
| 1550 | reportExperimentalFeatures, |
| 1551 | reactProductionProfiling, |
| 1552 | debugPrerender, |
| 1553 | bundler, |
| 1554 | }: LoadConfigOptions = {} |
| 1555 | ): Promise<NextConfigComplete> { |
| 1556 | // Generate cache key based on parameters that affect config output |
| 1557 | // Include process.pid to invalidate cache on server restart |
| 1558 | const cacheKey = getCacheKey( |
| 1559 | phase, |
| 1560 | dir, |
| 1561 | customConfig, |
| 1562 | reactProductionProfiling, |
| 1563 | debugPrerender, |
| 1564 | process.pid |
| 1565 | ) |
| 1566 | |
| 1567 | // Check if we have a cached result |
| 1568 | const cachedResult = configCache.get(cacheKey) |
| 1569 | if (cachedResult) { |
| 1570 | // Call the experimental features callback if provided |
| 1571 | if (reportExperimentalFeatures) { |
| 1572 | reportExperimentalFeatures(cachedResult.configuredExperimentalFeatures) |
| 1573 | } |
| 1574 | |
| 1575 | // Return raw config if requested and available |
| 1576 | if (rawConfig && cachedResult.rawConfig) { |
| 1577 | return cachedResult.rawConfig |
| 1578 | } |
| 1579 | |
| 1580 | return cachedResult.config |
| 1581 | } else { |
| 1582 | // Reset next.config errors before loading config |
| 1583 | // This happens on every config load to ensure fresh validation |
| 1584 | NextInstanceErrorState.nextConfig = [] |
| 1585 | } |
| 1586 | |
| 1587 | // Original implementation continues below... |
| 1588 | if (!process.env.__NEXT_PRIVATE_RENDER_WORKER) { |
| 1589 | try { |
| 1590 | loadWebpackHook() |
| 1591 | } catch (err) { |
| 1592 | // this can fail in standalone mode as the files |
| 1593 | // aren't traced/included |
| 1594 | if (!process.env.__NEXT_PRIVATE_STANDALONE_CONFIG) { |
| 1595 | throw err |
| 1596 | } |
| 1597 | } |
| 1598 | } |
| 1599 | |
| 1600 | if (process.env.__NEXT_PRIVATE_STANDALONE_CONFIG) { |
no test coverage detected
searching dependent graphs…