Repository navigation
Remove watched routes by the file that added them - #30
Open
everton-dgn wants to merge 1 commit into
Open
everton-dgn wants to merge 1 commit into
everton-dgn wants to merge 1 commit into
Conversation
removeRoute looked the entry up with toPath, which is not always the path the file produced. Saving or deleting a module that isn't a route removed a page with the same path, an entry from a custom toRoute outlived its file, and BaseFileSystemRouter with only toRoute threw on delete. Record the path each file produced and remove by that record.
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.
Fixes #29
removeRoutefound the entry withtoPath(src), which is not always the path thatsrcproduced. #29 has the cases and a repro.addRouteandupdateRoute.removeRoutelooks the path up there and does nothing for a file without a record. Falling back totoPathwould bring back theabout.tscase, wheretoPathgives the path of another file.removeRouteno longer callstoPath, soBaseFileSystemRouterwith onlytoRoutestops throwing. It also drops theisRoutecheck, since a recorded file passed it when it was added.addRouteorupdateRoutegets a path for a file that differs from the recorded one, it removes the old entry first. The router emitsremovefor the old path, thenaddfor the new one.When two files map to the same path (for example
about.mdxandabout.tsx), removing either one still removes the entry, as before. The other file keeps its record, so a later save of it adds the entry back.A subclass that calls
_addRoutedirectly bypasses the record, soremoveRoutedoes nothing for its files. Nothing in this repo does that;FlatFileSystemRouteronly overridestoPath.This is independent of #28. Both add a map to
BaseFileSystemRouter: #28 records the first source file per path, for ordering, and this one records the path per source file, for removal. They touch the same methods, so whichever lands second needs a small rebase.The three new tests in
test/convention.spec.tscover:toRoutethrough path changes onchangeandadd, an edit that makes it returnundefined, and a delete;BaseFileSystemRouterwith onlytoRoute.All three fail on
main.