Add gem extensions - #2711
Open
vinistock wants to merge 1 commit into
Open
Conversation
Morriar
reviewed
Sep 3, 2026
| # Extensions are loaded before the bundle is required so that they can patch the gems | ||
| # they apply to as those gems are being loaded. | ||
| ::Gem.find_files("tapioca/gem/extensions/*.rb").each do |extension| | ||
| require File.expand_path(extension) |
Contributor
There was a problem hiding this comment.
I wonder if we should also allow project-local files to be loaded as extensions?
Contributor
There was a problem hiding this comment.
Oh wait that's what prerequire is for right? I wonder if we should merge both concepts 🤔
Member
Author
There was a problem hiding this comment.
I agree that it ends up being the same concept, but with different names. I'm not sure how we should approach it though.
Simply removing prerequire and turning it into gem extensions would be a breaking change. We could also support both for some time or accept the distinct names for a bit until we're ready to make a breaking change.
WDYT?
vinistock
force-pushed
the
vs_add_gem_extensions
branch
from
September 3, 2026 19:15
c98e587 to
4887b5a
Compare
vinistock
marked this pull request as ready for review
September 4, 2026 14:54
KaanOzkan
approved these changes
Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
Similar to DSL extensions, it is useful to be able to patch certain behaviour to ensure accurate gem RBI generation. Gems can expose extensions that get required ahead of time, ensuring that they patch with Tapioca compatibility in mind.
The README and test included provide an example we hit recently that can be easily fixed with an extension.
Implementation
Very similar to DSL extensions. We use
Gem.find_filesto detect gem extensions contributed by gems and load them ahead of time, before generation starts.Tests
Added a test.