create-react-app-inner-buildpack icon indicating copy to clipboard operation
create-react-app-inner-buildpack copied to clipboard

Find all the files to alter in bash instead of ruby

Open sailor opened this issue 5 years ago • 0 comments

Related to the work started here https://github.com/mars/create-react-app-inner-buildpack/pull/21, this PR aims at reducing the boot time on big react applications (~1000 files).

For large projects, we can encounter R10 errors because the time spent trying to inject the environment variables on runtime can exceed the default timeout of 60 seconds.

This patch is reducing the amount of files pass to the ruby runtime (which is kind of slow), by greping first all the files containing the REACT_APP_VARS_AS_JSON (in bash). Only the files will be passed to the injectable_env.rb script.

On my local machine i get the following result with the patch:

time .profile.d/inject_react_app_env.sh
.profile.d/inject_react_app_env.sh  1.87s user 0.16s system 82% cpu 2.454 total

And without:

time .profile.d/inject_react_app_env.sh
.profile.d/inject_react_app_env.sh  13.07s user 6.86s system 90% cpu 22.003 total

which can be of a huge help for big apps.

sailor avatar Jan 07 '21 01:01 sailor