ai / size-limit

Calculate the real cost to run your JS app or lib to keep good performance. Show error in pull request if the cost exceeds the limit.
MIT License
6.52k stars 1.82k forks source link

multiple checks with `--why` only kept last `report.html` #311

Closed unional closed 1 year ago

unional commented 1 year ago

e.g.:

// package.json
{
  "size-limit": [
    {
      "path": "./cjs/index.js",
      "limit": "15 kb"
    },
    {
      "path": "./esm/index.js",
      "limit": "15 kb"
    },
    {
      "path": "./tslib/index.js",
      "limit": "15 kb"
    }
  ]
}

Running size-limit --why (using esbuild and esbuild-why) will create a report.html containing the result of the last one (tslib) as the previous ones are overwritten.

I can change it to add report-{x}.html, but a better way is giving each check a name, and name the output as report-{name}.html?

Currently the check contains a name, but it is the entry file name:

{
  path: './tslib/index.js',
  limit: '15 kb',
  files: [ 'D:\\code\\unional\\type-plus\\tslib\\index.js' ],
  name: './tslib/index.js',
  sizeLimit: 15000,
  ...
}
ai commented 1 year ago

but a better way is giving each check a name, and name the output as report-{name}.html?

check already has name but it could contain spaces.

Maybe report-1.html will be better.

unional commented 1 year ago

Just checked. I can config it:

    {
      "name": "tslib",
      "path": "./tslib/index.js",
      "limit": "15 kb"
    }

produce:

{
  name: 'tslib',
  path: './tslib/index.js',
  limit: '15 kb',
  files: [ 'D:\\code\\unional\\type-plus\\tslib\\index.js' ],
  sizeLimit: 15000,
  ...
}

I can use that and fall back to {n} if it contains invalid characters.

unional commented 1 year ago

Zero-based or one-based? 😛

esbuild-why-0.html vs esbuild-why-1.html

ai commented 1 year ago

Let’s start from 1 :)

unional commented 1 year ago

Yep, that's what I'm doing.