Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
LuckySwap
interface
Commits
a90318cb
Unverified
Commit
a90318cb
authored
Mar 09, 2023
by
Zach Pomerantz
Committed by
GitHub
Mar 09, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update test-size (#6118)
* fix: update test-size * fix: update main size
parent
93cf4b35
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
test-size.js
scripts/test-size.js
+10
-12
No files found.
scripts/test-size.js
View file @
a90318cb
...
@@ -16,10 +16,10 @@ try {
...
@@ -16,10 +16,10 @@ try {
}
}
// The last recorded size for these assets, as reported by `yarn build`.
// The last recorded size for these assets, as reported by `yarn build`.
const
MAX_SIZE_MAIN_KB
=
361.36
const
LAST_SIZE_MAIN_KB
=
374
// This is the async-loaded js, called <number>.<hash>.js, with a matching css file.
// This is the async-loaded js, called <number>.<hash>.js, with a matching css file.
const
MAX_SIZE_ENTRY_MB
=
1.38
const
LAST_SIZE_ENTRY_KB
=
1417
const
SIZE_TOLERANCE_KB
=
5
const
SIZE_TOLERANCE_KB
=
5
...
@@ -30,20 +30,22 @@ let fail = false
...
@@ -30,20 +30,22 @@ let fail = false
console
.
log
(
'
File sizes after gzip:
\n
'
)
console
.
log
(
'
File sizes after gzip:
\n
'
)
jsEntrypoints
.
forEach
((
entrypoint
)
=>
{
jsEntrypoints
.
forEach
((
entrypoint
)
=>
{
const
name
=
entrypoint
.
match
(
/
\/([\w\d
-
]
*
)\.
/
)[
1
]
const
name
=
entrypoint
.
match
(
/
\/([\w\d
-
]
*
)\.
/
)[
1
]
const
size
=
gzipSize
(
fs
.
readFileSync
(
path
.
join
(
buildDir
,
entrypoint
)))
const
size
=
gzipSize
(
fs
.
readFileSync
(
path
.
join
(
buildDir
,
entrypoint
)))
/
1024
let
maxSize
=
MAX_SIZE_ENTRY_MB
*
1024
*
1024
let
maxSize
=
LAST_SIZE_ENTRY_KB
+
SIZE_TOLERANCE_KB
if
(
name
===
'
runtime-main
'
)
{
if
(
name
===
'
runtime-main
'
)
{
return
return
}
else
if
(
name
===
'
main
'
)
{
}
else
if
(
name
===
'
main
'
)
{
maxSize
=
MAX_SIZE_MAIN_KB
*
1024
maxSize
=
LAST_SIZE_MAIN_KB
+
SIZE_TOLERANCE_KB
}
}
maxSize
+=
SIZE_TOLERANCE_KB
*
1024
const
report
=
`\t
${
size
.
toFixed
(
2
).
padEnd
(
8
)}
kB\t
${
chalk
.
dim
(
`max:
${
maxSize
.
toFixed
().
padEnd
(
4
)}
kB`
)}
\t
${
entrypoint
}
`
if
(
maxSize
>
size
)
{
if
(
maxSize
>
size
)
{
console
.
log
(
chalk
.
green
(
`\t
${
toKb
(
maxSize
)}
\t
${
entrypoint
}
`
))
console
.
log
(
chalk
.
green
(
report
))
}
else
{
}
else
{
console
.
log
(
chalk
.
red
(
`\t
${
toKb
(
maxSize
)}
\t
${
entrypoint
}
`
),
'
\t
did you import an unnecessary dependency?
'
)
console
.
log
(
chalk
.
red
(
report
),
'
\t
did you import an unnecessary dependency?
'
)
fail
=
true
fail
=
true
}
}
})
})
...
@@ -52,7 +54,3 @@ if (fail) {
...
@@ -52,7 +54,3 @@ if (fail) {
console
.
log
(
chalk
.
yellow
(
'
Reduce the file size or update the size limit (in scripts/test-size.js)
'
))
console
.
log
(
chalk
.
yellow
(
'
Reduce the file size or update the size limit (in scripts/test-size.js)
'
))
process
.
exit
(
1
)
process
.
exit
(
1
)
}
}
function
toKb
(
bytes
)
{
return
((
bytes
/
1024
).
toFixed
(
2
)
+
'
kB
'
).
padEnd
(
8
)
}
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