Loading custom extensions in addition to custom compilers
Hello,
I am trying to write a custom compiler for a gem that uses a DSL to add methods to Active Record model classes.
The problem is that the DSL simply calls define_singleton_method and does not maintain a list of the methods it defines. So there is no way to know which methods were defined by the gem when introspecting an Active Record model class.
After digging into the Tapioca repo, I saw that the compilers for delegated_type and has_secure_token have the same issue, and the workaround is to override the DSL methods to maintain a list of generated methods internally, using this extension.
I want to do something similar, however it looks like while Tapioca will look for custom compilers in the sorbet/tapioca/compilers directory, there is no equivalent for loading custom extensions. Extensions have to be loaded before the application, and the application is loaded before compilers, so I can't load the extension from the compiler.
Did I miss something, or is this something that is not currently supported? If not, would you be open to a PR to add support for this?
Good point. I don't see a reason not to support this. Implementation can be similar to the load_dsl_compilers method https://github.com/Shopify/tapioca/blob/fcbde0df4680a5a1897117bfa838c2eda0830b0c/lib/tapioca/loaders/dsl.rb#L63-L65
We actually have some work in progress about this: https://github.com/Shopify/tapioca/commit/12255bb93bf30a7dd32e5bbaf0e818ab1c9942ee
#1602 was merged a while back, so this can be closed :)