Prevent runtime autodetection on gem require #143
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changed the way
ExecJS.runtimeis defined so thatRuntimes.autodetectis called only when callingExecJS.runtimeand not when requiring the gem itself.Context
For the context, we work on a Rails application named Osuny and for optimization purposes, we were working on reducing the slug size of the application image on our hosting platform Scalingo.
For this, we wanted to remove the folder containing the
nodebinary as it is only used for asset compilation, and thus useless for application runtime. But removing it caused the application to fail on boot as ExecJS was trying to detect a JS runtime when starting the application.We managed to trace back the source to the
bootstrapgem being required, and following its dependencies, requiringautoprefixer-railsand thenexecjs, which in the require process, executes this line.That's why we proposed this change, which should not break anything but instead let ExecJS search its runtime only when necessary.