Skip to content
Source
Sign inSign up
TanStack/router

Compiler correctness: split-route exports and distinct re-export aliases #8505

Send to my agent
OpenSheraff(GitHub profile, opens in a new tab) opened this issue 0 comments

Reproduced on main at 763ac8b8ad with the Babel compiler (Node 24.8.0, pnpm 11.21.0). These failures were exposed by tests in #8504 and can be fixed independently of that migration.

Route exports with React HMR and code splitting

The 16-case Vite test uses target: 'react', autoCodeSplitting: true, and separate component/loader groups. After initial transformation and module loading:

  • export { helper as helperAlias } produces helperAlias === undefined while helper remains callable (six cases).
  • export class component {} loses the component export.
  • export { component as View } produces View === undefined while the route has a component.

Expected: preserve the public exports and their binding identities. All eight cases pass with autoCodeSplitting: false; all eight fail with it enabled. This reproduces before any hot update.

Related: #8455 addresses shared destructuring/name collisions during HMR, a different failure.

Distinct re-export aliases resolve to the same source

// server.ts
export { createServerOnlyFn as wrap } from '@tanstack/react-start'
// client.ts
export { createClientOnlyFn as wrap } from '@tanstack/react-start'
// barrel.ts
export { wrap as allowed } from './server'
export { wrap as denied } from './client'
// entry.ts
import { allowed, denied } from './barrel'
export const a = allowed(() => 'server-value')
export const b = denied(() => 'client-value')

In server output, a() should return 'server-value' and b() should throw. Instead, a() also throws createClientOnlyFn() functions can only be called on the client!.

extractModuleInfoFromAst keys both re-exports by wrap, so the second source overwrites the first. The executable compiler regression fails unchanged on main.

Sign in to join this conversation.