|
1 | 1 | import { loadEnvConfig } from '@next/env'
|
2 | 2 | import * as Log from '../../build/output/log'
|
3 |
| -import { bold, purple } from '../../lib/picocolors' |
| 3 | +import { bold, purple, strikethrough } from '../../lib/picocolors' |
4 | 4 | import {
|
5 | 5 | PHASE_DEVELOPMENT_SERVER,
|
6 | 6 | PHASE_PRODUCTION_BUILD,
|
7 | 7 | } from '../../shared/lib/constants'
|
8 | 8 | import loadConfig, { type ConfiguredExperimentalFeature } from '../config'
|
| 9 | +import { experimentalSchema } from '../config-schema' |
9 | 10 |
|
10 | 11 | export function logStartInfo({
|
11 | 12 | networkUrl,
|
@@ -47,21 +48,31 @@ export function logStartInfo({
|
47 | 48 | if (experimentalFeatures?.length) {
|
48 | 49 | Log.bootstrap(`- Experiments (use with caution):`)
|
49 | 50 | for (const exp of experimentalFeatures) {
|
50 |
| - const symbol = |
51 |
| - typeof exp.value === 'boolean' |
52 |
| - ? exp.value === true |
53 |
| - ? bold('✓') |
54 |
| - : bold('⨯') |
55 |
| - : '·' |
| 51 | + const isValid = Object.prototype.hasOwnProperty.call( |
| 52 | + experimentalSchema, |
| 53 | + exp.key |
| 54 | + ) |
| 55 | + if (isValid) { |
| 56 | + const symbol = |
| 57 | + typeof exp.value === 'boolean' |
| 58 | + ? exp.value === true |
| 59 | + ? bold('✓') |
| 60 | + : bold('⨯') |
| 61 | + : '·' |
56 | 62 |
|
57 |
| - const suffix = |
58 |
| - typeof exp.value === 'number' || typeof exp.value === 'string' |
59 |
| - ? `: ${JSON.stringify(exp.value)}` |
60 |
| - : '' |
| 63 | + const suffix = |
| 64 | + typeof exp.value === 'number' || typeof exp.value === 'string' |
| 65 | + ? `: ${JSON.stringify(exp.value)}` |
| 66 | + : '' |
61 | 67 |
|
62 |
| - const reason = exp.reason ? ` (${exp.reason})` : '' |
| 68 | + const reason = exp.reason ? ` (${exp.reason})` : '' |
63 | 69 |
|
64 |
| - Log.bootstrap(` ${symbol} ${exp.key}${suffix}${reason}`) |
| 70 | + Log.bootstrap(` ${symbol} ${exp.key}${suffix}${reason}`) |
| 71 | + } else { |
| 72 | + Log.bootstrap( |
| 73 | + ` ? ${strikethrough(exp.key)} (invalid experimental key)` |
| 74 | + ) |
| 75 | + } |
65 | 76 | }
|
66 | 77 | }
|
67 | 78 |
|
|
0 commit comments