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
6d80e6e5
Unverified
Commit
6d80e6e5
authored
Feb 03, 2021
by
JJ Kasper
Committed by
GitHub
Feb 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add version for stats (#21823)
Adds versioning for the stats output
parent
55365268
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
build-stats-plugin.ts
packages/next/build/webpack/plugins/build-stats-plugin.ts
+6
-1
index.test.js
test/integration/build-stats/test/index.test.js
+5
-2
No files found.
packages/next/build/webpack/plugins/build-stats-plugin.ts
View file @
6d80e6e5
...
@@ -6,6 +6,8 @@ import { spans } from './profiling-plugin'
...
@@ -6,6 +6,8 @@ import { spans } from './profiling-plugin'
import
{
webpack
}
from
'next/dist/compiled/webpack/webpack'
import
{
webpack
}
from
'next/dist/compiled/webpack/webpack'
import
{
tracer
,
traceAsyncFn
}
from
'../../tracer'
import
{
tracer
,
traceAsyncFn
}
from
'../../tracer'
const
STATS_VERSION
=
0
// This plugin creates a stats.json for a build when enabled
// This plugin creates a stats.json for a build when enabled
export
default
class
BuildStatsPlugin
{
export
default
class
BuildStatsPlugin
{
private
distDir
:
string
private
distDir
:
string
...
@@ -29,7 +31,10 @@ export default class BuildStatsPlugin {
...
@@ -29,7 +31,10 @@ export default class BuildStatsPlugin {
const
fileStream
=
fs
.
createWriteStream
(
const
fileStream
=
fs
.
createWriteStream
(
path
.
join
(
this
.
distDir
,
'next-stats.json'
)
path
.
join
(
this
.
distDir
,
'next-stats.json'
)
)
)
const
jsonStream
=
bfj
.
streamify
(
statsJson
)
const
jsonStream
=
bfj
.
streamify
({
version
:
STATS_VERSION
,
stats
:
statsJson
,
})
jsonStream
.
pipe
(
fileStream
)
jsonStream
.
pipe
(
fileStream
)
jsonStream
.
on
(
'error'
,
reject
)
jsonStream
.
on
(
'error'
,
reject
)
fileStream
.
on
(
'error'
,
reject
)
fileStream
.
on
(
'error'
,
reject
)
...
...
test/integration/build-stats/test/index.test.js
View file @
6d80e6e5
...
@@ -14,7 +14,10 @@ describe('Build Stats', () => {
...
@@ -14,7 +14,10 @@ describe('Build Stats', () => {
await
nextBuild
(
appDir
)
await
nextBuild
(
appDir
)
expect
(
await
fs
.
pathExists
(
statsPath
)).
toBe
(
true
)
expect
(
await
fs
.
pathExists
(
statsPath
)).
toBe
(
true
)
const
statsData
=
await
fs
.
readFile
(
statsPath
,
'utf8'
)
const
statsString
=
await
fs
.
readFile
(
statsPath
,
'utf8'
)
JSON
.
parse
(
statsData
)
const
statsData
=
JSON
.
parse
(
statsString
)
expect
(
statsData
.
version
).
toBe
(
0
)
expect
(
typeof
statsData
.
stats
).
toBe
(
'object'
)
})
})
})
})
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