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

v2 route file naming: route file convention not reading route folders correctly #5303

Closed
1 task done
lennerd opened this issue Jan 29, 2023 · 7 comments · Fixed by #5228
Closed
1 task done

v2 route file naming: route file convention not reading route folders correctly #5303

lennerd opened this issue Jan 29, 2023 · 7 comments · Fixed by #5228

Comments

@lennerd
Copy link

lennerd commented Jan 29, 2023

What version of Remix are you using?

1.11.1

Are all your remix dependencies & dev-dependencies using the same version?

  • Yes

Steps to Reproduce

1. Create a new Remix project by using npx create-remix@latest

2. Enable v2 routing convention

/** @type {import('@remix-run/dev').AppConfig} */
module.exports = {
  ignoredRouteFiles: ["**/.*"],
  future: {
    v2_routeConvention: true,
  },
};

3. Create a route folder tree as shown below

$ tree app/routes
app/routes
├── _app
│   └── index.tsx
└── _app._index.tsx

4. Run npx remix routes to see the evaluated routes

Expected Behavior

With the given folder tree above I would expect the output of npx remix routes to be as follows:

$ npx remix routes
<Routes>
  <Route file="root.tsx">
    <Route file="routes/_app/index.tsx">
      <Route index file="routes/_app._index.tsx" />
    </Route
  </Route>
</Routes>

routes/_app/index.tsx: a pathless route with _app defining a layout for all other routes prefixed with _app

routes/_app._index.tsx: an index route nested inside the layout route called _app

Actual Behavior

Currently npx remix routes errors when given the folder tree above:

$ npx remix routes
Error: Path undefined defined by route "_app/index" conflicts with route "_app._index"

When you remove _app/index.tsx folder route, you can see the error:

$ npx remix routes
<Routes>
  <Route file="root.tsx">
    <Route index file="routes/_app/index.tsx" />
  </Route>
</Routes>

routes/_app/index.tsx should not be recognized as an index route.

@ctrlplusb
Copy link

I used the following structure to wrap the "root" route in a folder;

|- app
   |- routes
      |- _index
         |- index.tsx

i.e. /app/routes/_index/index.tsx

@lennerd
Copy link
Author

lennerd commented Jan 30, 2023

@ctrlplusb what do you get, when you run npx remox routes?

@confix
Copy link
Contributor

confix commented Jan 31, 2023

I guess remix routes produces the error.

Given the following layout

| - app
    | - routes
        | - test.tsx 

produces the following routes output

<Routes>
  <Route file="root.tsx">
    <Route path="est" file="outes/test.tsx" />
  </Route>
</Routes>

It seems like some regression removes the first character, which for nested routes without nested URLs removes the underscore and produces a route with path parameter.

Applied to your example, _app/index.tsx turns into app/index.tsx and produces a route for /app. _app/_index.tsx is turned into app/_index.tsx. Now you routes collide.

@mcansh
Copy link
Collaborator

mcansh commented Jan 31, 2023

@confix both of these issues are resolved in #5228 which should have landed in yesterdays release but didn't make the train

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

@confix
Copy link
Contributor

confix commented Jan 31, 2023

@mcansh Ah, good to know. Gonna wait then. Thanks!

@MichaelDeBoey
Copy link
Member

Closed by #5228

@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2023

🤖 Hello there,

We just published version v0.0.0-nightly-a024557-20230207 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

Successfully merging a pull request may close this issue.

6 participants