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
26c438b4
Unverified
Commit
26c438b4
authored
Oct 27, 2020
by
JJ Kasper
Committed by
GitHub
Oct 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Record leveraged configs (#18175)
This records new configs being leveraged
parent
f773a1a4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
191 additions
and
0 deletions
+191
-0
index.ts
packages/next/build/index.ts
+3
-0
build.ts
packages/next/telemetry/events/build.ts
+3
-0
version.ts
packages/next/telemetry/events/version.ts
+36
-0
next.config.custom-routes
test/integration/telemetry/next.config.custom-routes
+38
-0
next.config.i18n-images
test/integration/telemetry/next.config.i18n-images
+24
-0
index.test.js
test/integration/telemetry/test/index.test.js
+87
-0
No files found.
packages/next/build/index.ts
View file @
26c438b4
...
@@ -1048,6 +1048,9 @@ export default async function build(
...
@@ -1048,6 +1048,9 @@ export default async function build(
(
staticPages
.
size
+
ssgPages
.
size
+
serverPropsPages
.
size
),
(
staticPages
.
size
+
ssgPages
.
size
+
serverPropsPages
.
size
),
hasStatic404
:
useStatic404
,
hasStatic404
:
useStatic404
,
hasReportWebVitals
:
namedExports
?.
includes
(
'reportWebVitals'
)
??
false
,
hasReportWebVitals
:
namedExports
?.
includes
(
'reportWebVitals'
)
??
false
,
rewritesCount
:
rewrites
.
length
,
headersCount
:
headers
.
length
,
redirectsCount
:
redirects
.
length
-
1
,
// reduce one for trailing slash
})
})
)
)
...
...
packages/next/telemetry/events/build.ts
View file @
26c438b4
...
@@ -45,6 +45,9 @@ type EventBuildOptimized = {
...
@@ -45,6 +45,9 @@ type EventBuildOptimized = {
hasTestPages
:
boolean
hasTestPages
:
boolean
hasStatic404
:
boolean
hasStatic404
:
boolean
hasReportWebVitals
:
boolean
hasReportWebVitals
:
boolean
headersCount
:
number
rewritesCount
:
number
redirectsCount
:
number
}
}
export
function
eventBuildOptimize
(
export
function
eventBuildOptimize
(
...
...
packages/next/telemetry/events/version.ts
View file @
26c438b4
...
@@ -21,6 +21,17 @@ type EventCliSessionStarted = {
...
@@ -21,6 +21,17 @@ type EventCliSessionStarted = {
buildTarget
:
string
buildTarget
:
string
hasWebpackConfig
:
boolean
hasWebpackConfig
:
boolean
hasBabelConfig
:
boolean
hasBabelConfig
:
boolean
basePathEnabled
:
boolean
i18nEnabled
:
boolean
imageEnabled
:
boolean
locales
:
string
|
null
localeDomainsCount
:
number
|
null
localeDetectionEnabled
:
boolean
|
null
imageDomainsCount
:
number
|
null
imageSizes
:
string
|
null
imageLoader
:
string
|
null
trailingSlashEnabled
:
boolean
reactStrictMode
:
boolean
}
}
function
hasBabelConfig
(
dir
:
string
):
boolean
{
function
hasBabelConfig
(
dir
:
string
):
boolean
{
...
@@ -83,6 +94,17 @@ export function eventCliSession(
...
@@ -83,6 +94,17 @@ export function eventCliSession(
|
'buildTarget'
|
'buildTarget'
|
'hasWebpackConfig'
|
'hasWebpackConfig'
|
'hasBabelConfig'
|
'hasBabelConfig'
|
'basePathEnabled'
|
'i18nEnabled'
|
'imageEnabled'
|
'locales'
|
'localeDomainsCount'
|
'localeDetectionEnabled'
|
'imageDomainsCount'
|
'imageSizes'
|
'imageLoader'
|
'trailingSlashEnabled'
|
'reactStrictMode'
>
>
):
{
eventName
:
string
;
payload
:
EventCliSessionStarted
}[]
{
):
{
eventName
:
string
;
payload
:
EventCliSessionStarted
}[]
{
// This should be an invariant, if it fails our build tooling is broken.
// This should be an invariant, if it fails our build tooling is broken.
...
@@ -92,6 +114,9 @@ export function eventCliSession(
...
@@ -92,6 +114,9 @@ export function eventCliSession(
const
userConfiguration
=
getNextConfig
(
phase
,
dir
)
const
userConfiguration
=
getNextConfig
(
phase
,
dir
)
const
{
images
,
experimental
}
=
userConfiguration
||
{}
const
{
i18n
}
=
experimental
||
{}
const
payload
:
EventCliSessionStarted
=
{
const
payload
:
EventCliSessionStarted
=
{
nextVersion
:
process
.
env
.
__NEXT_VERSION
,
nextVersion
:
process
.
env
.
__NEXT_VERSION
,
nodeVersion
:
process
.
version
,
nodeVersion
:
process
.
version
,
...
@@ -103,6 +128,17 @@ export function eventCliSession(
...
@@ -103,6 +128,17 @@ export function eventCliSession(
buildTarget
:
userConfiguration
?.
target
??
'default'
,
buildTarget
:
userConfiguration
?.
target
??
'default'
,
hasWebpackConfig
:
typeof
userConfiguration
?.
webpack
===
'function'
,
hasWebpackConfig
:
typeof
userConfiguration
?.
webpack
===
'function'
,
hasBabelConfig
:
hasBabelConfig
(
dir
),
hasBabelConfig
:
hasBabelConfig
(
dir
),
imageEnabled
:
!!
images
,
basePathEnabled
:
!!
userConfiguration
?.
basePath
,
i18nEnabled
:
!!
i18n
,
locales
:
i18n
?.
locales
?
i18n
.
locales
.
join
(
','
)
:
null
,
localeDomainsCount
:
i18n
?.
domains
?
i18n
.
domains
.
length
:
null
,
localeDetectionEnabled
:
!
i18n
?
null
:
i18n
.
localeDetection
!==
false
,
imageDomainsCount
:
images
?.
domains
?
images
.
domains
.
length
:
null
,
imageSizes
:
images
?.
sizes
?
images
.
sizes
.
join
(
','
)
:
null
,
imageLoader
:
images
?.
loader
,
trailingSlashEnabled
:
!!
userConfiguration
?.
trailingSlash
,
reactStrictMode
:
!!
userConfiguration
?.
reactStrictMode
,
}
}
return
[{
eventName
:
EVENT_VERSION
,
payload
}]
return
[{
eventName
:
EVENT_VERSION
,
payload
}]
}
}
test/integration/telemetry/next.config.custom-routes
0 → 100644
View file @
26c438b4
module.exports = phase => {
return {
rewrites() {
return [
{
source: '/hello-1',
destination: '/world'
},
{
source: '/hello-2',
destination: '/world'
},
]
},
redirects() {
return [
{
source: '/hello-3',
destination: '/world',
permanent: false
}
]
},
headers() {
return [
{
source: '/hello-4',
headers: [
{
key: 'x-path',
value: 'hello-4'
}
]
}
]
}
}
}
test/integration/telemetry/next.config.i18n-images
0 → 100644
View file @
26c438b4
module.exports = phase => {
return {
images: {
sizes: [64, 128, 256, 512, 1024],
domains: ['example.com'],
},
experimental: {
i18n: {
locales: ['en','nl','fr'],
defaultLocale: 'en',
domains: [
{
domain: 'example.com',
defaultLocale: 'en'
},
{
domain: 'example.fr',
defaultLocale: 'fr'
}
]
}
}
}
}
test/integration/telemetry/test/index.test.js
View file @
26c438b4
...
@@ -420,4 +420,91 @@ describe('Telemetry CLI', () => {
...
@@ -420,4 +420,91 @@ describe('Telemetry CLI', () => {
event1
=
/NEXT_BUILD_OPTIMIZED
[\s\S]
+
?
{
([\s\S]
+
?)
}/
.
exec
(
build
.
stderr
).
pop
()
event1
=
/NEXT_BUILD_OPTIMIZED
[\s\S]
+
?
{
([\s\S]
+
?)
}/
.
exec
(
build
.
stderr
).
pop
()
expect
(
event1
).
toMatch
(
/hasReportWebVitals.*
?
false/
)
expect
(
event1
).
toMatch
(
/hasReportWebVitals.*
?
false/
)
})
})
it
(
'detects rewrites, headers, and redirects for next build'
,
async
()
=>
{
await
fs
.
rename
(
path
.
join
(
appDir
,
'next.config.custom-routes'
),
path
.
join
(
appDir
,
'next.config.js'
)
)
const
{
stderr
}
=
await
nextBuild
(
appDir
,
[],
{
stderr
:
true
,
env
:
{
NEXT_TELEMETRY_DEBUG
:
1
},
})
await
fs
.
rename
(
path
.
join
(
appDir
,
'next.config.js'
),
path
.
join
(
appDir
,
'next.config.custom-routes'
)
)
const
event1
=
/NEXT_BUILD_OPTIMIZED
[\s\S]
+
?
{
([\s\S]
+
?)
}/
.
exec
(
stderr
).
pop
()
expect
(
event1
).
toMatch
(
/"headersCount": 1/
)
expect
(
event1
).
toMatch
(
/"rewritesCount": 2/
)
expect
(
event1
).
toMatch
(
/"redirectsCount": 1/
)
})
it
(
'detects i18n and image configs for session start'
,
async
()
=>
{
await
fs
.
rename
(
path
.
join
(
appDir
,
'next.config.i18n-images'
),
path
.
join
(
appDir
,
'next.config.js'
)
)
const
{
stderr
}
=
await
nextBuild
(
appDir
,
[],
{
stderr
:
true
,
env
:
{
NEXT_TELEMETRY_DEBUG
:
1
},
})
await
fs
.
rename
(
path
.
join
(
appDir
,
'next.config.js'
),
path
.
join
(
appDir
,
'next.config.i18n-images'
)
)
const
event1
=
/NEXT_CLI_SESSION_STARTED
[\s\S]
+
?
{
([\s\S]
+
?)
}/
.
exec
(
stderr
)
.
pop
()
expect
(
event1
).
toMatch
(
/"i18nEnabled": true/
)
expect
(
event1
).
toMatch
(
/"locales": "en,nl,fr"/
)
expect
(
event1
).
toMatch
(
/"localeDomainsCount": 2/
)
expect
(
event1
).
toMatch
(
/"localeDetectionEnabled": true/
)
expect
(
event1
).
toMatch
(
/"imageDomainsCount": 1/
)
expect
(
event1
).
toMatch
(
/"imageSizes": "64,128,256,512,1024"/
)
expect
(
event1
).
toMatch
(
/"trailingSlashEnabled": false/
)
expect
(
event1
).
toMatch
(
/"reactStrictMode": false/
)
await
fs
.
rename
(
path
.
join
(
appDir
,
'next.config.i18n-images'
),
path
.
join
(
appDir
,
'next.config.js'
)
)
let
stderr2
=
''
let
app
=
await
launchApp
(
appDir
,
await
findPort
(),
{
onStderr
(
msg
)
{
stderr2
+=
msg
||
''
},
env
:
{
NEXT_TELEMETRY_DEBUG
:
1
,
},
})
await
waitFor
(
1000
)
await
killApp
(
app
)
await
fs
.
rename
(
path
.
join
(
appDir
,
'next.config.js'
),
path
.
join
(
appDir
,
'next.config.i18n-images'
)
)
const
event2
=
/NEXT_CLI_SESSION_STARTED
[\s\S]
+
?
{
([\s\S]
+
?)
}/
.
exec
(
stderr2
)
.
pop
()
expect
(
event2
).
toMatch
(
/"i18nEnabled": true/
)
expect
(
event2
).
toMatch
(
/"locales": "en,nl,fr"/
)
expect
(
event2
).
toMatch
(
/"localeDomainsCount": 2/
)
expect
(
event2
).
toMatch
(
/"localeDetectionEnabled": true/
)
expect
(
event2
).
toMatch
(
/"imageDomainsCount": 1/
)
expect
(
event2
).
toMatch
(
/"imageSizes": "64,128,256,512,1024"/
)
expect
(
event2
).
toMatch
(
/"trailingSlashEnabled": false/
)
expect
(
event2
).
toMatch
(
/"reactStrictMode": false/
)
})
})
})
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