Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

alanorozco
Copy link
Member

Sort file lists in bundle-size summaries so that they're quicker to read.

  1. Groups by filename without extension, so the equivalent .mjs file is always next to .js
  2. Sorts by delta, either asc or desc depending on pre-approval.


/**
* @param {{file: string, bundleSizeDelta: number}[]} items
* @param {'asc'|'desc'} sizeOrder
Copy link
Member

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

Comment on lines +77 to +81
const noExtension = file => {
const parts = file.split('.');
parts.pop();
return parts.join('.');
};
Copy link
Member

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:

Suggested change
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'

Comment on lines +144 to +148
// 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');
Copy link
Member

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 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants