-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sort bundle-size
summary lists
#1568
base: main
Are you sure you want to change the base?
Conversation
|
||
/** | ||
* @param {{file: string, bundleSizeDelta: number}[]} items | ||
* @param {'asc'|'desc'} sizeOrder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I doubt we'll ever really need both options, we can simplify the code by just assuming desc
const noExtension = file => { | ||
const parts = file.split('.'); | ||
parts.pop(); | ||
return parts.join('.'); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is basically "the opposite of path.extname
", so how about use it in the definition of this function and make it a oneliner:
const noExtension = file => { | |
const parts = file.split('.'); | |
parts.pop(); | |
return parts.join('.'); | |
}; | |
const noExtension = file => file.slice(0, -path.extname(file).length); |
(Add const path = require('path');
at the top, ofc)
Tested this locally to make sure it works, e.g.:
> fn = 'a/b/adasds.max.js';
'a/b/adasds.max.js'
> const noExtension = file => file.slice(0, -path.extname(file).length);
undefined
> noExtension(fn);
'a/b/adasds.max'
// If files don't require approval, we're firstly interested in the | ||
// smallest delta, so we sort asc | ||
sortBundleSizeItems(bundleSizeDeltasAutoApproved, 'asc') | ||
.map(formatBundleSizeItem) | ||
.join('\n'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh, I think it's fine to sort both cases as desc - it creates a consistent reading experience 🤷♂️
Sort file lists in
bundle-size
summaries so that they're quicker to read..mjs
file is always next to.js
asc
ordesc
depending on pre-approval.