Option to filter reported sections or allow passing custom options via command line
I have a monorepo with dozens of libraries. The value exported by the .size-limit.js module is built dynamically as an array of sections (i.e. {name: string, path: string}[]). Running the script with the --why option opens dozens of tabs on my browser. Ideally, I can pick one or more sections for introspection.
I tried passing custom options to modify the generated configuration, but size-limit bails when unknown options are passed via the command line. Ignoring unknown options is also a good enough solution for me as that would allow me to use a custom option to filter the results.
Do you have an idea how to fix it?
Take a look at #201 and let me know what you think.
Will it be a better idea to pass environment variable? Like:
SHOW_WHY_FOR=3 npx size-limit
Environment variable is more easy to use in your code (process.env.SHOW_WHY_FOR), they do not require us to remove unknown argument error.
Yeah, using environment variables is an option. My current workaround is to refer to the package directly after reviewing the bundle sizes.
npx size-limit --why ./path/to/package
I understand if you feel this is not the right direction for this library given I can already introspect the packages individually.
We can add --why NAME support to the @size-limit/webpack and size-limit. NAME is a name: value from Size Limit config.
Do you like this API? You can send PR.