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
bc813796
Unverified
Commit
bc813796
authored
Feb 04, 2020
by
Joe Haddad
Committed by
GitHub
Feb 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect Invalid Pages Before Optimize (#10418)
parent
44e234e9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
17 deletions
+36
-17
index.ts
packages/next/build/index.ts
+7
-8
build.ts
packages/next/telemetry/events/build.ts
+22
-7
index.test.js
test/integration/telemetry/test/index.test.js
+7
-2
No files found.
packages/next/build/index.ts
View file @
bc813796
import
chalk
from
'chalk'
import
ciEnvironment
from
'ci-info'
import
escapeStringRegexp
from
'escape-string-regexp'
import
findUp
from
'find-up'
import
fs
from
'fs'
import
Worker
from
'jest-worker'
...
...
@@ -11,14 +12,14 @@ import { promisify } from 'util'
import
formatWebpackMessages
from
'../client/dev/error-overlay/format-webpack-messages'
import
checkCustomRoutes
,
{
getRedirectStatus
,
RouteType
,
Header
,
Redirect
,
Rewrite
,
Header
,
RouteType
,
}
from
'../lib/check-custom-routes'
import
{
PUBLIC_DIR_MIDDLEWARE_CONFLICT
,
PAGES_404_GET_INITIAL_PROPS_ERROR
,
PUBLIC_DIR_MIDDLEWARE_CONFLICT
,
}
from
'../lib/constants'
import
{
findPagesDir
}
from
'../lib/find-pages-dir'
import
{
recursiveDelete
}
from
'../lib/recursive-delete'
...
...
@@ -44,7 +45,7 @@ import loadConfig, {
isTargetLikeServerless
,
}
from
'../next-server/server/config'
import
{
eventBuild
Duration
,
eventBuild
Completed
,
eventBuildOptimize
,
eventNextPlugins
,
eventVersion
,
...
...
@@ -56,17 +57,16 @@ import { generateBuildId } from './generate-build-id'
import
{
isWriteable
}
from
'./is-writeable'
import
createSpinner
from
'./spinner'
import
{
isPageStatic
,
collectPages
,
getPageSizeInKb
,
hasCustomAppGetInitialProps
,
isPageStatic
,
PageInfo
,
printCustomRoutes
,
printTreeView
,
}
from
'./utils'
import
getBaseWebpackConfig
from
'./webpack-config'
import
{
writeBuildId
}
from
'./write-build-id'
import
escapeStringRegexp
from
'escape-string-regexp'
const
fsAccess
=
promisify
(
fs
.
access
)
const
fsUnlink
=
promisify
(
fs
.
unlink
)
...
...
@@ -394,8 +394,7 @@ export default async function build(dir: string, conf = null): Promise<void> {
}
else
{
console
.
log
(
chalk
.
green
(
'Compiled successfully.
\
n'
))
telemetry
.
record
(
eventBuildDuration
({
totalPageCount
:
pagePaths
.
length
,
eventBuildCompleted
(
pagePaths
,
{
durationInSeconds
:
webpackBuildEnd
[
0
],
})
)
...
...
packages/next/telemetry/events/build.ts
View file @
bc813796
const
REGEXP_DIRECTORY_DUNDER
=
/
[\\/]
__
[^\\/]
+
(?<
!
[\\/]
__
(?:
tests|mocks
))
__
[\\/]
/i
const
REGEXP_DIRECTORY_TESTS
=
/
[\\/]
__
(
tests|mocks
)
__
[\\/]
/i
const
REGEXP_FILE_TEST
=
/
\.(?:
spec|test
)\.[^
.
]
+$/i
const
EVENT_BUILD_DURATION
=
'NEXT_BUILD_COMPLETED'
type
EventBuildCompleted
=
{
durationInSeconds
:
number
totalPageCount
:
number
hasDunderPages
:
boolean
hasTestPages
:
boolean
}
export
function
eventBuildDuration
(
event
:
EventBuildCompleted
export
function
eventBuildCompleted
(
pagePaths
:
string
[],
event
:
Omit
<
EventBuildCompleted
,
'totalPageCount'
|
'hasDunderPages'
|
'hasTestPages'
>
):
{
eventName
:
string
;
payload
:
EventBuildCompleted
}
{
return
{
eventName
:
EVENT_BUILD_DURATION
,
payload
:
event
,
payload
:
{
...
event
,
totalPageCount
:
pagePaths
.
length
,
hasDunderPages
:
pagePaths
.
some
(
path
=>
REGEXP_DIRECTORY_DUNDER
.
test
(
path
)
),
hasTestPages
:
pagePaths
.
some
(
path
=>
REGEXP_DIRECTORY_TESTS
.
test
(
path
)
||
REGEXP_FILE_TEST
.
test
(
path
)
),
},
}
}
...
...
@@ -23,10 +42,6 @@ type EventBuildOptimized = {
hasTestPages
:
boolean
}
const
REGEXP_DIRECTORY_DUNDER
=
/
[\\/]
__
[^\\/]
+
(?<
!
[\\/]
__
(?:
tests|mocks
))
__
[\\/]
/i
const
REGEXP_DIRECTORY_TESTS
=
/
[\\/]
__
(
tests|mocks
)
__
[\\/]
/i
const
REGEXP_FILE_TEST
=
/
\.(?:
spec|test
)\.[^
.
]
+$/i
export
function
eventBuildOptimize
(
pagePaths
:
string
[],
event
:
Omit
<
...
...
test/integration/telemetry/test/index.test.js
View file @
bc813796
...
...
@@ -108,8 +108,13 @@ describe('Telemetry CLI', () => {
path
.
join
(
appDir
,
'pages'
,
'hello.test.skip'
)
)
expect
(
stderr
).
toMatch
(
/hasDunderPages.*
?
true/
)
expect
(
stderr
).
toMatch
(
/hasTestPages.*
?
true/
)
const
event1
=
/NEXT_BUILD_COMPLETED
[\s\S]
+
?
{
([\s\S]
+
?)
}/
.
exec
(
stderr
).
pop
()
expect
(
event1
).
toMatch
(
/hasDunderPages.*
?
true/
)
expect
(
event1
).
toMatch
(
/hasTestPages.*
?
true/
)
const
event2
=
/NEXT_BUILD_OPTIMIZED
[\s\S]
+
?
{
([\s\S]
+
?)
}/
.
exec
(
stderr
).
pop
()
expect
(
event2
).
toMatch
(
/hasDunderPages.*
?
true/
)
expect
(
event2
).
toMatch
(
/hasTestPages.*
?
true/
)
})
it
(
'detects isSrcDir dir correctly for `next dev`'
,
async
()
=>
{
...
...
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