Skip to content

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

Closed

Description

@lennerd

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.

Activity

  1. ctrlplusb commented on Jan 30, 2023

    @ctrlplusb

    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

  2. lennerd commented on Jan 30, 2023

    @lennerd
    ContributorAuthor

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

  3. confix commented on Jan 31, 2023

    @confix
    Contributor

    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.

  4. mcansh commented on Jan 31, 2023

    @mcansh
    Contributor

    @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>
  5. confix commented on Jan 31, 2023

    @confix
    Contributor

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

  6. MichaelDeBoey commented on Feb 6, 2023

    @MichaelDeBoey
    Member

    Closed by #5228

  7. github-actions commented on Feb 7, 2023

    @github-actions
    Contributor

    🤖 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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions