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
Need less entries in require.rb
#818
Conversation
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.
Nice!
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.
Will this work with gems that aren't supposed to be loaded by default? For example fakefs?
An alternative solution to having those gems as require: false
could be to pass them into the exclude
config. I took a brief look and feels like the exclude
might be handled after loading all the dependencies with bundler? If that's the case I don't see how we can circumvent fakefs
issue with this feature.
Indeed, gems like
Agreed, we should probably not change the default auto-require behaviour of any gem that is excluded from RBI generation. |
cef1306
to
261c6d4
Compare
Co-authored-by: Alexandre Terrasa <583144+Morriar@users.noreply.github.com>
Co-authored-by: Alexandre Terrasa <583144+Morriar@users.noreply.github.com>
Co-authored-by: Alexandre Terrasa <583144+Morriar@users.noreply.github.com>
Co-authored-by: Alexandre Terrasa <583144+Morriar@users.noreply.github.com>
Co-authored-by: Alexandre Terrasa <583144+Morriar@users.noreply.github.com>
261c6d4
to
ee595f6
Compare
@KaanOzkan We implemented the exclusion of excluded gems from being forcibly required and updated the test to check for that too. Do you mind re-reviewing? |
Motivation
Contributes to #429
As things stand right now, we need to add all gems that are marked as
require: false
in theGemfile
to thetapioca/require.rb
file manually. If we made Bundler load those gems by default, we would not need any of those entries.Implementation
We are able to get Bundler to load gems by tricking it to think that gems marked as
require: false
are actuallyrequire: true
. We do that by intercepting theautorequire
attr reader and changing all[]
(which meanrequire: false
) values tonil
(which meanrequire: true
).Tests
Added a test with a gem explicitly marked as
require: false
, and verified that the gem is loaded and Tapioca can generate an RBI for it without needing atapioca/require.rb
entry.