Add tapioca/dsl
entrypoint for custom DSL compilers
#844
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
When writing a custom DSL compiler, the client code needs to require a minimal set of files from Tapioca, so that the DSL compiler can be loaded in isolation and tested inside the project. However, we don't have an entrypoint for that minimal require set and clients end up having to do
require "tapioca/internal"
to achieve this, which is not great.Implementation
This PR adds a
tapioca/dsl
entrypoint, which DSL compiler classes can add as a require.Tests
The test is super custom, since I wanted to test the experience of a client app declaring and loading a custom DSL compiler in isolation from the Tapioca CLI runner. When we load the Tapioca CLI
dsl
command and, that, in turn, loads custom compilers, everything works regardless of any Tapioca requires, since the CLI already bring everything with it.The custom test defines a small executable inside the mock project that loads the custom compiler and tries to generate an RBI using it, just as how tests would do it. That allows us to test the loading and operation of a custom DSL compiler in isolation using only the minimal
tapioca/dsl
require.