Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reintroduce flat routing #1482

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Brendonovich
Copy link
Contributor

@Brendonovich Brendonovich commented May 18, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • infrastructure changes
  • Other... Please describe:

What is the current behavior?

Changes to nested route escaping in RC0 broke what was essentially flat routing, where files/folders named along the lines of a.b.c would have their path become a/b/c. This is useful for reducing folder nested. Whether it was an intentional behaviour previously I'm not sure, but I'd like it to be there.

What is the new behavior?

Adds back the . -> / regex that was removed in RC0, bringing back flat route support.

Other information

Having flat routing alongside nested routing does add the potential for multiple definitions of the same route, but IMO the convenience outweighs that risk

Copy link

changeset-bot bot commented May 18, 2024

🦋 Changeset detected

Latest commit: 59094aa

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ryansolid
Copy link
Member

One thing I wasn't sure about here was what this did for people who wanted . in the path. I added it to solve unnesting very briefly and almost immediately regretted it. That's why I went back against this because I could already picture the issues being opened when someone made route.json.ts and it wasn't at route.json. There are cases where people make extension specific routes at minimum. Especially for known things like... manifest.json etc. I know Remix does flat routing. Did they ever solve this?

@Brendonovich
Copy link
Contributor Author

Looks like Remix use [] to escape characters, whether that's individual periods with manifest[.]json.ts or entire file names like [manifest.json].ts. They use $ as their dynamic route prefix similar to how SS uses : so there's no conflict with dynamic files, but they also use $.ts on its own (which i quite like tbh) to do splat routes, whereas for us doing something like [...rest].tsx would conflict with our splat routes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants