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
8f4e265f
Unverified
Commit
8f4e265f
authored
Apr 06, 2020
by
Aaron Reisman
Committed by
GitHub
Apr 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Utility Types (#11077)
parent
7a61fb7f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
16 deletions
+11
-16
collect-plugins.ts
packages/next/build/plugins/collect-plugins.ts
+1
-8
utils.ts
packages/next/next-server/lib/utils.ts
+10
-8
No files found.
packages/next/build/plugins/collect-plugins.ts
View file @
8f4e265f
...
@@ -134,11 +134,6 @@ async function collectPluginMeta(
...
@@ -134,11 +134,6 @@ async function collectPluginMeta(
}
}
}
}
type
SeparatedPlugins
=
{
appMiddlewarePlugins
:
PluginMetaData
[]
documentMiddlewarePlugins
:
PluginMetaData
[]
}
// clean package name so it can be used as variable
// clean package name so it can be used as variable
export
const
getPluginId
=
(
pkg
:
string
):
string
=>
{
export
const
getPluginId
=
(
pkg
:
string
):
string
=>
{
pkg
=
pkg
.
replace
(
/
\W
/g
,
''
)
pkg
=
pkg
.
replace
(
/
\W
/g
,
''
)
...
@@ -254,6 +249,4 @@ async function _collectPlugins(
...
@@ -254,6 +249,4 @@ async function _collectPlugins(
// only execute it once between server/client configs
// only execute it once between server/client configs
// since the plugins need to match
// since the plugins need to match
export
const
collectPlugins
=
execOnce
(
export
const
collectPlugins
=
execOnce
(
_collectPlugins
)
_collectPlugins
)
as
typeof
_collectPlugins
packages/next/next-server/lib/utils.ts
View file @
8f4e265f
...
@@ -239,17 +239,19 @@ export type NextApiHandler<T = any> = (
...
@@ -239,17 +239,19 @@ export type NextApiHandler<T = any> = (
/**
/**
* Utils
* Utils
*/
*/
export
function
execOnce
(
this
:
any
,
fn
:
(...
args
:
any
)
=>
any
)
{
export
function
execOnce
<
T
extends
(...
args
:
any
[])
=>
ReturnType
<
T
>>
(
fn
:
T
):
T
{
let
used
=
false
let
used
=
false
let
result
:
any
=
null
let
result
:
ReturnType
<
T
>
return
(
...
args
:
any
)
=>
{
return
(
(...
args
:
any
[]
)
=>
{
if
(
!
used
)
{
if
(
!
used
)
{
used
=
true
used
=
true
result
=
fn
.
apply
(
this
,
args
)
result
=
fn
(...
args
)
}
}
return
result
return
result
}
}
)
as
T
}
}
export
function
getLocationOrigin
()
{
export
function
getLocationOrigin
()
{
...
@@ -263,7 +265,7 @@ export function getURL() {
...
@@ -263,7 +265,7 @@ export function getURL() {
return
href
.
substring
(
origin
.
length
)
return
href
.
substring
(
origin
.
length
)
}
}
export
function
getDisplayName
(
Component
:
ComponentType
<
any
>
)
{
export
function
getDisplayName
<
P
>
(
Component
:
ComponentType
<
P
>
)
{
return
typeof
Component
===
'string'
return
typeof
Component
===
'string'
?
Component
?
Component
:
Component
.
displayName
||
Component
.
name
||
'Unknown'
:
Component
.
displayName
||
Component
.
name
||
'Unknown'
...
@@ -296,7 +298,7 @@ export async function loadGetInitialProps<
...
@@ -296,7 +298,7 @@ export async function loadGetInitialProps<
pageProps
:
await
loadGetInitialProps
(
ctx
.
Component
,
ctx
.
ctx
),
pageProps
:
await
loadGetInitialProps
(
ctx
.
Component
,
ctx
.
ctx
),
}
}
}
}
return
{}
as
any
return
{}
as
IP
}
}
const
props
=
await
App
.
getInitialProps
(
ctx
)
const
props
=
await
App
.
getInitialProps
(
ctx
)
...
@@ -356,7 +358,7 @@ export function formatWithValidation(
...
@@ -356,7 +358,7 @@ export function formatWithValidation(
}
}
}
}
return
format
(
url
as
any
,
options
)
return
format
(
url
as
URL
,
options
)
}
}
export
const
SP
=
typeof
performance
!==
'undefined'
export
const
SP
=
typeof
performance
!==
'undefined'
...
...
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