Skip to content

autoCodeSplitting causes error with destructured export: "Property name expected type of string but got undefined" #4787

@LeCarbonator

Description

@LeCarbonator

Which project does this relate to?

Router

Describe the bug

When creating destructured exports like so:

export { a, b } = someFunction()

It appears to work as expected. However, if you import a or b and attempt to use them, it causes an error:

[plugin:tanstack-router:code-splitter:compile-virtual-file] Property name expected type of string but got undefined

/home/projects/tanstack-router-htjxkgnt/src/routes/about.tsx

This issue is a reduced replication of a TanStack Form issue 1634. Since TanStack Form is no longer part of the reproducible example, I've closed that issue and opened one here. Please let me know if TanStack Form needs adjustments or the like.

Your Example Website or App

https://stackblitz.com/edit/tanstack-router-htjxkgnt?file=vite.config.js

Steps to Reproduce the Bug or Issue

  1. Boot up the page
  2. Attempt to navigate to 'About'. You should see the error pop up.
  3. Go to vite.config.ts and set autoCodeSplitting: false
  4. You should now be able to navigate to 'About'

Expected behavior

As a user, I expect destructured exports to work regardless of nesting level with code splitting enabled.

Screenshots or Videos

No response

Platform

  • Router / Start Version: react-router v1.129.8
  • OS: Windows 11
  • Browser: Librewolf (Firefox)
  • Browser Version: 140.0.4-1
  • Bundler: Vite
  • Bundler Version: 6.3.5

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