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

Option to filter reported sections or allow passing custom options via command line #200

Open
ctumolosus opened this issue Sep 15, 2020 · 5 comments

Comments

@ctumolosus
Copy link

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.

@ai
Copy link
Owner

ai commented Sep 15, 2020

Do you have an idea how to fix it?

@ctumolosus
Copy link
Author

Take a look at #201 and let me know what you think.

@ai
Copy link
Owner

ai commented Sep 16, 2020

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.

@ctumolosus
Copy link
Author

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.

@ai
Copy link
Owner

ai commented Sep 16, 2020

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.

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 a pull request may close this issue.

2 participants