-
Notifications
You must be signed in to change notification settings - Fork 14
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
chore: add 'optionalDependencies' to package.json #13
base: main
Are you sure you want to change the base?
Conversation
Preview is readyThis pull request generated a Preview👀 Preview: https://preview-13--gatsby.preview.vtex.app |
Lighthouse ReportsHere are the Lighthouse reports of this Pull Request
|
@@ -56,50 +56,52 @@ | |||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know much about this, but when WebOps builds for production, doesn't it already skip all the devDependencies
because NODE_ENV
is set to production
(I'd hope)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@filipewl It does not because it has to run the tests and the lighthouse checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But for building the static pages, I don't think they need to install the dev dependencies...
The tests and LH checks are run on their own separate pipeline run and in these cases they do install the dev dependencies to run the proper commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@filipewl, indeed the devDependencies are not needed for building the static pages, as well as the tests and LH checks have separate pipelines.
However, if you look at our tekton dashboard and browse the pipelines' code, you'll notice that they share the same common task, called clone
. This clone
task is responsible for, among other things, running yarn install
for the cloned repo in the CI environment. Since this task is shared between pipelines, we need to fill the optionalDependencies
with the packages used in all pipelines, letting out only things we use locally, such as the storybook
and eslint
.
I agree that different tasks like clone-for-test
and clone-for-build
would be better, but:
yarn
does not support other sections besidesoptionalDependencies
. If they had support fortestDependencies
andbuildDependencies
that would be great.- The impact on the time is minimal as per the benchmarks I've run (adding cypress and lighthouse dependencies adds ~4s comparing to when only using the build dependencies)
We could investigate alternatives about to reduce the install time even further, maybe at webops level we could run different yarn install
commands depending on the pipeline. But that is a story for another PR :)
Converted this to draft until webops#84 is merged and I can test the full build pipeline to evaluate which |
- Move dependencies that are not necessary to build the application to 'optionalDependencies' - A faster yarn install can now be performed with 'yarn install --ignore-optional'
ecc282f
to
b8f21ad
Compare
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Make sure |
0715be6
to
d7d81ec
Compare
- This boolean env var allows us to choose if yarn install will be run with the '--ignore-optional' flag when running the CI
d7d81ec
to
abbf797
Compare
What's the purpose of this pull request?
This PR adds the
optionalDependencies
section atpackage.json
and adds dependencies that are not necessary to build the application to it.This was made so the build time is reduced, since we are now skipping unnecessary build dependencies such as
eslint
andstorybook
. A faster yarn install can now be performed withyarn install --ignore-optional
Benchmarks (at my local development machine):
rm -rf node_modules && yarn install
rm -rf node_modules && yarn install --ignore-optional
optionalDependencies
We can observe a 37.19% reduction in the execution time of
yarn install
when using the--ignore-optional
flag.How does it work?
By using the
optionalDependencies
category, we can now only install packages that we are really going to use during build time.This PR on webops-infra updates the gatsby build script to run
yarn install
with the--ignore-optional
flag.How to test it?
Basically, replicate the benchmarks mentioned in the first section. Here's a guide:
yarn install
, with and without the--ignore-optional
flagyarn build