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

🗺 Flat Routes #4483

Closed
2 of 3 tasks
ryanflorence opened this issue Nov 1, 2022 · 7 comments
Closed
2 of 3 tasks

🗺 Flat Routes #4483

ryanflorence opened this issue Nov 1, 2022 · 7 comments
Assignees
Milestone

Comments

@ryanflorence
Copy link
Member

ryanflorence commented Nov 1, 2022

An improved file system route convention to help route visibility and module co-location.

Progress

Community Implementation

https://github.com/kiliman/remix-flat-routes

@ryanflorence ryanflorence moved this from RFC to In Progress in Roadmap Nov 8, 2022
@ryanflorence ryanflorence self-assigned this Nov 11, 2022
@ryanflorence ryanflorence mentioned this issue Nov 14, 2022
2 tasks
@ryanflorence
Copy link
Member Author

@kiliman has offered to send a PR :)

@kiliman
Copy link
Collaborator

kiliman commented Nov 27, 2022 via email

kiliman added a commit to kiliman/remix that referenced this issue Nov 30, 2022
@remix-run remix-run locked as off-topic and limited conversation to collaborators Nov 30, 2022
@kiliman
Copy link
Collaborator

kiliman commented Nov 30, 2022

Initial PR #4716

@ryanflorence ryanflorence assigned mcansh and unassigned ryanflorence Dec 13, 2022
kiliman added a commit to kiliman/remix that referenced this issue Dec 13, 2022
mcansh pushed a commit that referenced this issue Dec 14, 2022
mcansh pushed a commit that referenced this issue Dec 20, 2022
@mcansh
Copy link
Collaborator

mcansh commented Jan 3, 2023

Next Steps: @pcattori to review updates #4880

mcansh added a commit that referenced this issue Jan 5, 2023
* feat: add flat routes convention

Closes #4483

* chore: include future v2_routeConvention flag

Integrates flat routes function into config

* fix: update readConfig test to include new v2_routeConvention flag

* fix: replace default route dir

Oops!

* chore: slim

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: remove unused eslint-disable coment

Signed-off-by: Logan McAnsh <logan@mcan.sh>

chore: use invariant instead of enforcing the type

Signed-off-by: Logan McAnsh <logan@mcan.sh>

chore: use for...of

Signed-off-by: Logan McAnsh <logan@mcan.sh>

chore: remove .route

Signed-off-by: Logan McAnsh <logan@mcan.sh>

chore: use _index for index routes

Signed-off-by: Logan McAnsh <logan@mcan.sh>

chore: replace magic characters with defined variable

Signed-off-by: Logan McAnsh <logan@mcan.sh>

fix: update default parentRoutePath

Signed-off-by: Logan McAnsh <logan@mcan.sh>

test: add test cases from old route convention

Signed-off-by: Logan McAnsh <logan@mcan.sh>

chore: update handling of special characters

Signed-off-by: Logan McAnsh <logan@mcan.sh>

chore: export route convention helpers

Signed-off-by: Logan McAnsh <logan@mcan.sh>

chore(flat-routes): add support for optional and escape route segments

Signed-off-by: Logan McAnsh <logan@mcan.sh>

chore(flat-routes): add support for optional and escape route segments

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore(flat-routes): add support for optional and escape route segments

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* initial import

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: index routes use underscores

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* feat: add support for optional segments

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: flat routes

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* feat: nested escaping inside optional

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: remove TODO comment

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* feat: handle opting out of parent layout, but keeping url segment

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: use `isSegmentSeparator` to account for windows paths

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: helpers no longer need to be exported from `routesConvention`

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: don't return separators from `getRouteSegments`

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: rename test

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: don't treat escaped separator as new segment

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: undo some unneeded changes to `routesConvention`

Signed-off-by: Logan McAnsh <logan@mcan.sh>

chore: undo some unneeded changes to `routesConvention`

Signed-off-by: Logan McAnsh <logan@mcan.sh>

chore: undo some unneeded changes to `routesConvention`

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* test: route hierarchy

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* test: add more test cases

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* fix: glob

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: handle opting out of layout

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: lil clean

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: more tests, add substate type

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: re-add lookahead/lookbehind when exiting optional/escape modes

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: remove duplicate cases

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* test: update test name

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: advance char earlier, fix bugggg

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: prevent `/` in route segments

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* test: update test name

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* test: add cases for splitBySegments

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* test: add cases for joinByDelimiter

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* Update packages/remix-dev/config/flat-routes.ts

Co-authored-by: Pedro Cattori <pcattori@gmail.com>

* Update packages/remix-dev/config/flat-routes.ts

Co-authored-by: Pedro Cattori <pcattori@gmail.com>

* Update packages/remix-dev/config/flat-routes.ts

Co-authored-by: Pedro Cattori <pcattori@gmail.com>

* test: remove duplicate routes

should update duplicate route detection by using route path instead of fs path

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: combine jacob's and kiliman's approaches

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: remove console.log

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* test: add tests for generically creating route paths

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* test: add case for skipping layouts other than the top level

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: make tests pass on windows

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: use for...of to be consistent

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: for...of on routeMap

Co-authored-by: Pedro Cattori <pcattori@gmail.com>

* fixup! chore: for...of on routeMap

* chore: extract getRouteMap

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: address feedback

Co-authored-by: Pedro Cattori <pcattori@gmail.com>
Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: set default parentId to "root" in defineRoutes

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* test: update defineConventionalRoutes test for default root parentId

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: remove comment

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: remove unnecessary else block

Co-authored-by: Pedro Cattori <pcattori@gmail.com>
Signed-off-by: Logan McAnsh <logan@mcan.sh>

* test: update defineRoutes test per 4779e24

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: add brief description of what each state/substate means

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: remove nesting via early return

Co-authored-by: Pedro Cattori <pcattori@gmail.com>

* chore: condense state/substate

Co-authored-by: Pedro Cattori <pcattori@gmail.com>
Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: update routePaths to account for folders

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: error when escaping `:` or `*`

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: remove console.log

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: include routeId in error message

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: error when using `:` or `*`, not just escaping

Signed-off-by: Logan McAnsh <logan@mcan.sh>

* chore: normalize error messages, move tests to getRouteSegments

Signed-off-by: Logan McAnsh <logan@mcan.sh>

Signed-off-by: Logan McAnsh <logan@mcan.sh>
Co-authored-by: kiliman <kiliman@gmail.com>
Co-authored-by: Pedro Cattori <pcattori@gmail.com>
@mcansh mcansh moved this from In Progress to Merged in Roadmap Jan 5, 2023
@mcansh
Copy link
Collaborator

mcansh commented Jan 5, 2023

merged!

@mcansh mcansh closed this as completed Jan 5, 2023
@kiliman
Copy link
Collaborator

kiliman commented Jan 5, 2023

Awesome!

image

@machour
Copy link
Collaborator

machour commented Jan 6, 2023

Awesome!
We need to document this before shipping it in a release

@chaance chaance moved this from Merged to Released in Roadmap Jan 19, 2023
@ryanflorence ryanflorence moved this from Released to Remix 1.11 in Roadmap Feb 16, 2023
@ryanflorence ryanflorence added this to the v1.11 milestone Feb 16, 2023
@ryanflorence ryanflorence moved this from Remix 1.11 to Released in Roadmap Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

4 participants