Commit e5e74dab authored by JJ Kasper's avatar JJ Kasper Committed by Tim Neutkens

Add warning for experimental config usage (#7985)

* Add warning for experimental config usage

* Update config.ts
parent 718a36e1
...@@ -180,7 +180,7 @@ export type NextApiResponse<T = any> = ServerResponse & { ...@@ -180,7 +180,7 @@ export type NextApiResponse<T = any> = ServerResponse & {
/** /**
* Utils * Utils
*/ */
export function execOnce(this: any, fn: () => any) { export function execOnce(this: any, fn: (...args: any) => any) {
let used = false let used = false
return (...args: any) => { return (...args: any) => {
if (!used) { if (!used) {
......
import os from 'os' import os from 'os'
import findUp from 'find-up' import findUp from 'find-up'
import { CONFIG_FILE } from '../lib/constants' import { CONFIG_FILE } from '../lib/constants'
import { execOnce } from '../lib/utils'
const targets = ['server', 'serverless'] const targets = ['server', 'serverless']
...@@ -43,8 +44,18 @@ const defaultConfig: { [key: string]: any } = { ...@@ -43,8 +44,18 @@ const defaultConfig: { [key: string]: any } = {
publicRuntimeConfig: {}, publicRuntimeConfig: {},
} }
const experimentalWarning = execOnce(() => {
console.warn(
`\nFound experimental config:\nExperimental features can change at anytime and aren't officially supported (use at your own risk).\n`
)
})
function assignDefaults(userConfig: { [key: string]: any }) { function assignDefaults(userConfig: { [key: string]: any }) {
Object.keys(userConfig).forEach((key: string) => { Object.keys(userConfig).forEach((key: string) => {
if (key === 'experimental' && userConfig[key]) {
experimentalWarning()
}
const maybeObject = userConfig[key] const maybeObject = userConfig[key]
if (!!maybeObject && maybeObject.constructor === Object) { if (!!maybeObject && maybeObject.constructor === Object) {
userConfig[key] = { userConfig[key] = {
......
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