Skip to content

Route generation does not allow plain template literals anymore after 1.166.31 #7216

@kompot

Description

@kompot

Which project does this relate to?

Router

Describe the bug

Code that worked in router-cli@1.166.30 and below

const routeVarOfferDefinition = `/offers` as const;

const routeApi = getRouteApi(
  `/$locale/_main/(offers)${routeVarOfferDefinition}/$actionId/$tab`,
);

export const Route = createFileRoute(
  `/$locale/_main/(offers)${routeVarOfferDefinition}/$actionId/$tab`,
)({

now in 1.166.31+ throws this error during route generation

Error: Error transforming route file /front/spa/src/routes/$locale/_main/(offers)/-offer/$actionId/$tab.tsx: 
Error: expected route id to be a string literal or plain template literal in /$locale/_main/(offers)/offers/$actionId/$tab

We were relying heavily on semi dynamic URLs (we generate routeVarOfferDefinition like consts during prepare step before TanStack Router kicks in) and actually the error implies that it should work but does not.

I guess this PR is to blame
#7167

Your Example Website or App

https://stackblitz.com/edit/github-t8vtvecd?file=src%2Froutes%2Fabout.tsx,package.json

Steps to Reproduce the Bug or Issue

  1. Go to https://stackblitz.com/edit/github-t8vtvecd?file=src%2Froutes%2Fabout.tsx,package.json
  2. Ctrl + c in terminal
  3. tsr generate -> all good
  4. update version to 1.166.31
  5. npm install
  6. tsr generate fails with expected route id to be a string literal or plain template literal as About page has dynamic part.

Expected behavior

I would expect it to continute working. One of the best Tanstack Router features for our platform as we need to support deep variations for different markets.

Screenshots or Videos

No response

Platform

@tanstack/router-cli@1.166.30

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions