Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
e5e74dab
Commit
e5e74dab
authored
Jul 16, 2019
by
JJ Kasper
Committed by
Tim Neutkens
Jul 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add warning for experimental config usage (#7985)
* Add warning for experimental config usage * Update config.ts
parent
718a36e1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
utils.ts
packages/next-server/lib/utils.ts
+1
-1
config.ts
packages/next-server/server/config.ts
+11
-0
No files found.
packages/next-server/lib/utils.ts
View file @
e5e74dab
...
@@ -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
)
{
...
...
packages/next-server/server/config.ts
View file @
e5e74dab
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
]
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment