Closed zavodnyuk closed 1 year ago
I think global install is antipattern. What reasons do you have for that in your case?
I want to have separate gitlab jobs in pipeline like Build -> Check bundle size . Each job is isolated, so to be able to run size-limit I need whether install all dependencies (which takes around 5 minutes in my project) or cache node_modules and pass to the next job (takes around 3 minutes), though I only want to check file size. So eventually I want to have separate jobs and optimize dependency installation by limiting installation only specific packages. It should improve overall job time and resources. Btw, why it's antipattern?
How do you use lock file for global install?
How do you use lock file for global install?
I don't really think I need any kind of lock file, that's why I was thinking about global installation. I just want to check file size with size-limit
lib config file and output experience
Without lock file the Size Limit results can be different (esbuild update can change size changes). Also, we are not talking about security risks.
I still think it is a bad practice.
For your case, you can install Size Limit locally for size task:
npm install --save-dev @size-limit/file size-limit
npx size-limit
I am encountering an issue while trying to use the
@size-limit/file
plugin locally without installing all the dependencies in my project. Currently, I am utilizing thesize-limit
library in conjunction with a file plugin. In my project's Gitlab CI/CD configuration, I have a job that verifies if the built bundle size is under a specified threshold. However, I would like to have a separate job where I can pass the bundle as an artifact, and then runsize-limit
using that dedicated job.The problem I am facing is that I do not want to pass the entire
node_modules
directory as cache nor install all the dependencies from scratch in the dedicated job. When I attempt to install bothsize-limit
and@size-limit/file
globally and runsize-limit
inside the project folder, it returns an error stating that it could not find thefile
plugin locally. I noticed a screenshot in the README that suggests I might be able to usesize-limit
through npx, but unfortunately, it does not work for me.I would appreciate any suggestions or guidance on how I can avoid running npm install in this job and installing all the dependencies while still being able to utilize the
@size-limit/file
plugin successfully. Imagine I have bundle files and only thing I want is to fail the job if file size if above the limits.Thank you for your assistance!