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

Flatten route folders should not consider colocated files as routes #5028

Closed
manzano78 opened this issue Jan 9, 2023 · 4 comments
Closed
Assignees

Comments

@manzano78
Copy link
Contributor

What version of Remix are you using?

v0.0.0-nightly-45d4491-20230106

Steps to Reproduce

  • Install the nightly release which contains the new flatten routes convention:
    npx create-remix@v0.0.0-nightly-45d4491-20230106
  • Activate the future flag in the remix.config.js file:
future: { 
  v2_routeConvention: true
}
  • Apply the following routes. Make footer.tsx and primary-nav.tsx files export a default component.
routes/
   app/
      _index.tsx
      primary-nav.tsx
      footer.tsx
  • Execute the following command to see what are the resulting routes handled by Remix:
    npx remix routes

Expected Behavior

<Routes>
  <Route file="root.tsx">
    <Route path="app" index file="routes/app/_index.tsx" />
  </Route>
</Routes>

Actual Behavior

<Routes>
  <Route file="root.tsx">
    <Route path="app" index file="routes/app/_index.tsx" />
    <Route path="app/footer" file="routes/app/footer.tsx" />
    <Route path="app/primary-nav" file="routes/app/primary-nav.tsx" />
  </Route>
</Routes>

Only _index.tsx should be considered as a route. Everything else should be ignored because considered as colocated files, as @kiliman says here:

#4880 (comment)

@manzano78 You should probably create a new issue instead of commenting on a closed PR.

Anyway, yes. If you are using flat-folders convention (where routes are folder names instead of filenames), then _index.tsx should be treated as the route and everything else as colocated files.

Can you run npx remix routes and paste the result? Please do so in another issue and reference this comment.

Thanks!

@kiliman
Copy link
Collaborator

kiliman commented Jan 9, 2023

Looks like a bug in the Remix core version. It's working fine with remix-flat-routes package.

❯ tree app/routes-remix-5028/
app/routes-remix-5028/
└── app
    ├── _index.tsx
    ├── footer.tsx
    └── primary-nav.tsx
 npx remix routes
<Routes>
  <Route file="root.tsx">
    <Route path="app" file="routes-remix-5028/app/_index.tsx" />
  </Route>
</Routes>

@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version v0.0.0-nightly-f5475db-20230111 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version 1.10.1-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version 1.10.1 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

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

No branches or pull requests

3 participants