onedesign / generator-one-base

A foundation for One Design Company projects on the web.
Other
1 stars 1 forks source link

Consider options for batching yarn installs across generators #165

Open cmalven opened 6 years ago

cmalven commented 6 years ago

I had noticed that v2 of the generator seemed to be significantly slower to finish than the same tasks in v1, so I decided to run a side-by-side test. Both arrive at almost identical project installs:

v1 34.63 seconds

v2 52.75 seconds

I'm pretty sure the difference between the two is almost entirely because of the difference in how they handle yarn installs.

Yarn is very efficient at optimizing package installation, and part of how it does this is by pre-calculating the shared dependencies between all of the packages it is about to install, and and optimizing/caching package installation.

With v1 we were running yarn only once or twice every time the generator is run; once for dev dependencies and once for all other dependencies. With v2, we run yarn 4 or more separate times, which means that yarn can't optimize installation across any of those runs.

Its not huge big deal, I'm willing to wait a minute to run the generator, but if there was any way we can optimize yarn installs across all composed generators it would be a sizable performance improvement.

brianjhanson commented 6 years ago

I think it should be possible to only run yarnInstall once by pushing our dependencies to an array throughout the process, then only running yarnInstall in the parent generator's index file.