andresz1 / size-limit-action

Compare the real cost to run your JS app or lib to keep good performance in every pull request
ISC License
449 stars 83 forks source link

feat: Add `package_manager` option to set manager in the config #87

Closed PilotConway closed 2 years ago

PilotConway commented 2 years ago

This PR would add a package_manager option to the configuration of the action to manually specify the package manager to use and skip auto detection. Issue #77.

Details

Although the script option is useful for specifying the script to use to configure the size-limit script to run and can be used in monorepos to only run a specific workspace (using yarn workspace package1 size-limit --json for instance), this still runs the install and build scripts on the entire repo which can drastically increase build times for larger monorepos and add increase costs. We tried using directory option to specific just the directory to run, but in doing so the yarn.lock file is not in those subfolders so npm was used which didn't work in our repo.

This new option allows users to manually specify the package manager to use such as yarn in this situation, allowing us to combine directory option with a monorepo to just build and install a single subpackage reducing time and costs and allowing for more configuration of the tool.

Tests

I have created a small test repo to show the use case my team is using, with two actions one using the original action and another using this PR. In the repo I blocked npm usage to show the action failing that is calling npm and the PR will succeed since package_manager: yarn is used in the config.

https://github.com/PilotConway/size-limit-monorepo-test/pull/1

inomdzhon commented 1 year ago

Hi, @andresz1 👋

I see, we have package_manager in a documentation, but we haven't got this property in a last version (current is 1.7.0) =(

Could we release minor version?

Thanks, and thanks @PilotConway for PR :)

mendrew commented 1 year ago

Hi @andresz1

could you please release a new version of this wonderful package? 🙏 We really miss this package_manager feature as it allows to run size-limit-action within monorepo package.

There is a hacky workaround, though. We currently create fake yarn.lock to let action detect yarn automatically, but we struggles, especially as feature in the documentation but not in the npm.

Thank you in advance!