Skip to content

[File-based routing] Route definitions with backtick/template literals are not automatically updated if file renamed/moved #4087

Open
@longzheng

Description

@longzheng

Which project does this relate to?

Router

Describe the bug

When using file-based routing, the build plugin/CLI should automatically update route configuration definitions when you rename a route file or even move a route file to another directory.

This process is broken if you use backticks or template literals in the createFileRoute/createLazyFileRoute function parameter.

For example the following route configuration will not be updated

export const Route = createFileRoute(`/about`)({
   ...

Even though the generator automatically inserts single quotes, the function parameter might be changed to backticks by an ESLint rule to enforce backticks since it makes it easier to add variables to strings.

'@stylistic/quotes': [`error`, `backtick`]

Your Example Website or App

https://stackblitz.com/edit/github-kop2fu1y?file=src%2Froutes%2Fabout.tsx

Steps to Reproduce the Bug or Issue

  1. Rename about.tsx to test.tsx

Expected behavior

Route config should automatically be updated with the new route.

export const Route = createFileRoute(`/test`)({

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: N/A
  • Version: 1.119.0

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    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