autoCodeSplitting: imported component used as both component and pendingComponent is left undefined (ReferenceError)
I maintainer di solito rispondono entro 1 giorno
@Sheraff ci sta già lavorando.
Dal 25/10/2026.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 67/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript, vite
- Ambito
- build-system
Direzione di ricerca
Start in the router plugin’s auto code splitting transform, which handles route component imports; the issue does not name a source file or test. Reproduce with the examples/react/start-bare route and inspect the built server and client router chunks for the missing Page binding. Done when the imported component remains correctly bound when used as both component and pendingComponent, and the route runs without a ReferenceError.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Which project does this relate to?
Start
Describe the bug
With autoCodeSplitting: true, a component that is imported from another module and used as both component and pendingComponent ends up as a free identifier in the built router chunk.
component becomes lazyRouteComponent($$splitComponentImporter, "component"), pendingComponent: Page stays in the main chunk, and the import { Page } is removed. vite build exits 0, but the chunk throws when it is evaluated (server request, or Start prerender):
ReferenceError: Page is not defined
at file:///.../dist/server/assets/router-DsEmb4my.js:40:20
at ModuleJob.run (node:internal/modules/esm/module_job:569:25)
at async node:internal/modules/esm/loader:650:26
at async Promise.all (index 0)
at async loadEntries (file:///.../dist/server/server.js:6766:52)
The client chunk has the same pendingComponent:Page with no binding.
Not affected: a component declared in the route file and used for both keys (it goes to a ?tsr-shared=1 module), and a separate pending component.
// src/routes/about.tsx
import { createFileRoute } from '@tanstack/react-router'
import { Page } from '~/components/Page'
export const Route = createFileRoute('/about')({
loader: () => new Promise((r) => setTimeout(r, 500)),
component: Page,
pendingComponent: Page,
})
Built server chunk:
var Route = createFileRoute("/about")({
loader: () => new Promise((r) => setTimeout(r, 500)),
component: lazyRouteComponent($$splitComponentImporter, "component"),
pendingComponent: Page
});
Workaround: codeSplitGroupings: [['component', 'pendingComponent']] on the route.
Complete minimal reproducer
https://github.com/cpeaustriajc/tanstack-router-shared-pending-component-repro
Steps to Reproduce the Bug
The repo is examples/react/start-bare with src/routes/about.tsx changed and src/components/Page.tsx added.
pnpm installpnpm vite buildgrep -n pendingComponent dist/server/assets/router-*.jsshowspendingComponent: Page, and the chunk has no import or declaration ofPage.pnpm startand open/about:ReferenceError: Page is not defined.
Control: change to pendingComponent: () => <p>Loading</p>. The build output has no free identifier and /about renders.
Expected behavior
The import stays in the main chunk while pendingComponent (not split) still references it, or the binding is shared the same way as a component declared in the route file.
Screenshots or Videos
No response
Platform
- Router / Start Version: @tanstack/react-router 1.170.46, @tanstack/react-start 1.169.5, @tanstack/router-plugin 1.169.0, @tanstack/start-plugin-core 1.171.56 (also seen on router-plugin 1.168.48)
- OS: macOS
- Browser: n/a (fails on the server)
- Browser Version: n/a
- Bundler: vite
- Bundler Version: 8.3.6
- Node: 26.12.1
Additional context
This issue was written with an AI assistant (Claude) and checked by running the reproducer from a fresh clone.
- Lingua principale
- TypeScript
- Stelle
- 15.3k
- Fork
- 1.9k
- Merge medio
- 1g 5h
- PR unite (30g)
- 46
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TanStack/router
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Masked navigation drops the first character of the hash each time (__tempLocation hash missing '#')Forse già presa @hassanabrar202 l’ha presa 8 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
router-generator: lazy-load Prettier (costs ~300–450ms per build even when formatting is off)Forse già presa @Sheraff l’ha presa 27 giorni fa. Apertapackage: router-generator performance
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
router-generator: sibling `physical()` subtrees in a virtual route config generate duplicate identifiersForse già presa @Sheraff l’ha presa 27 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
docs(router): clarify static title fallback in SPA modeForse già presa @Rohan-Dedhia l’ha presa 17 giorni fa. Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di TanStack/router
Issue simili
-
[BUG]: Shared links drop the configured basePath on GitHub PagesForse già presa @anshulchikhale30-p l’ha presa oggi. Apertabug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
StabilityNexus/IdentityTokens-EVM-Frontend#182 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Add: GTrekkerApertacheck:passed streams:add
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Koenkk/zigbee-herdsman-converters#13900 ·
I maintainer di solito rispondono entro 1 giorno
-
area: ui Bug Payload OSS
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
payloadcms/payload#19839 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
jeanibarz/knowledge-base-mcp-server#1291 ·
I maintainer di solito rispondono entro 1 giorno