-
Notifications
You must be signed in to change notification settings - Fork 27.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display experimental features for next build (#57152)
Display full information of experimental features in `next build`, so we'll have full insights for build logs Close NEXT-1697 * `next build` <img width="668" alt="image" src="https://github.com/vercel/next.js/assets/4800338/6ab75923-0336-4624-905f-347fedbff5a9">
- Loading branch information
Showing
5 changed files
with
170 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { loadEnvConfig } from '@next/env' | ||
import * as Log from '../../build/output/log' | ||
import { bold, purple } from '../../lib/picocolors' | ||
import { PHASE_DEVELOPMENT_SERVER } from '../../shared/lib/constants' | ||
import loadConfig, { getEnabledExperimentalFeatures } from '../config' | ||
|
||
export function logStartInfo({ | ||
networkUrl, | ||
appUrl, | ||
envInfo, | ||
expFeatureInfo, | ||
formatDurationText, | ||
maxExperimentalFeatures, | ||
}: { | ||
networkUrl: string | null | ||
appUrl: string | null | ||
formatDurationText: string | null | ||
maxExperimentalFeatures?: number | ||
envInfo?: string[] | ||
expFeatureInfo?: string[] | ||
}) { | ||
Log.bootstrap( | ||
bold(purple(`${Log.prefixes.ready} Next.js ${process.env.__NEXT_VERSION}`)) | ||
) | ||
if (appUrl) { | ||
Log.bootstrap(`- Local: ${appUrl}`) | ||
} | ||
if (networkUrl) { | ||
Log.bootstrap(`- Network: ${networkUrl}`) | ||
} | ||
if (envInfo?.length) Log.bootstrap(`- Environments: ${envInfo.join(', ')}`) | ||
|
||
if (expFeatureInfo?.length) { | ||
Log.bootstrap(`- Experiments (use at your own risk):`) | ||
// only show maximum 3 flags | ||
for (const exp of expFeatureInfo.slice(0, maxExperimentalFeatures)) { | ||
Log.bootstrap(` · ${exp}`) | ||
} | ||
/* ${expFeatureInfo.length - 3} more */ | ||
if (expFeatureInfo.length > 3 && maxExperimentalFeatures) { | ||
Log.bootstrap(` · ...`) | ||
} | ||
} | ||
|
||
// New line after the bootstrap info | ||
Log.info('') | ||
if (formatDurationText) { | ||
Log.event(`Ready in ${formatDurationText}`) | ||
} | ||
} | ||
|
||
export async function getStartServerInfo(dir: string): Promise<{ | ||
envInfo?: string[] | ||
expFeatureInfo?: string[] | ||
}> { | ||
let expFeatureInfo: string[] = [] | ||
await loadConfig(PHASE_DEVELOPMENT_SERVER, dir, { | ||
onLoadUserConfig(userConfig) { | ||
const userNextConfigExperimental = getEnabledExperimentalFeatures( | ||
userConfig.experimental | ||
) | ||
expFeatureInfo = userNextConfigExperimental.sort( | ||
(a, b) => a.length - b.length | ||
) | ||
}, | ||
}) | ||
|
||
// we need to reset env if we are going to create | ||
// the worker process with the esm loader so that the | ||
// initial env state is correct | ||
let envInfo: string[] = [] | ||
const { loadedEnvFiles } = loadEnvConfig(dir, true, console, false) | ||
if (loadedEnvFiles.length > 0) { | ||
envInfo = loadedEnvFiles.map((f) => f.path) | ||
} | ||
|
||
return { | ||
envInfo, | ||
expFeatureInfo, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.