Repository navigation
fix(core): support several generateRegistry hooks - #126
Merged
Merged
Conversation
The routes scanner holds a single filter, so the last registry's filter won and every output got the same routes.
Export Route and Path helpers from each generated registry and allow secondary registries to disable global augmentation. Keep augmentation enabled by default for Inertia compatibility. Apply independent route filters when several registry hooks share a scanner, and make regex filters repeatable. Co-authored-by: Simone Stefani <s.stefani95@gmail.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a17e12-c61e-7508-ac05-d5676d3d8cf3
Owner
|
Thanksss Simone Just added a follow up for the types: both generated registries were still augmenting the same global each registry now exports its own Route/Path type helpers, and |
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.
generateRegistrytakesoutputandroutes: { only, except }, which suggests registering it several times — e.g. one registry for a public SPA without backoffice routes, and one for an Inertia admin app with only those. Today that doesn't work: the hook applies its filter withroutesScanner.filter(), and the assembler's scanner holds a single filter (this.#filter = filterFn). The last registered hook wins, and every output gets the same routes.This change:
getScannedRoutes()by each generator's ownonly/exceptbefore writing its output.filterRouteto takePick<RoutesListItem, 'name'>, so it accepts scanned routes too.The new test registers two hooks against a scanner that, like the assembler's, keeps one filter. It fails on
mainand passes here.