autoCodeSplitting: imported component used as both component and pendingComponent is left undefined (ReferenceError)
Maintainer thường phản hồi trong vòng 1 ngày
@Sheraff đang làm issue này rồi.
Từ ngày 25/10/2026.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 67/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript, vite
- Lĩnh vực
- build-system
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 15.3k
- Fork
- 1.9k
- Merge trung bình
- 1 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 46
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TanStack/router
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Masked navigation drops the first character of the hash each time (__tempLocation hash missing '#')Có thể đã có người làm @hassanabrar202 đã nhận 8 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
router-generator: lazy-load Prettier (costs ~300–450ms per build even when formatting is off)Có thể đã có người làm @Sheraff đã nhận 27 ngày trước. Đang mởpackage: router-generator performance
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
router-generator: sibling `physical()` subtrees in a virtual route config generate duplicate identifiersCó thể đã có người làm @Sheraff đã nhận 27 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
docs(router): clarify static title fallback in SPA modeCó thể đã có người làm @Rohan-Dedhia đã nhận 17 ngày trước. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của TanStack/router
Issue tương tự
-
[BUG]: Shared links drop the configured basePath on GitHub PagesCó thể đã có người làm @anshulchikhale30-p đã nhận hôm nay. Đang mởbug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
StabilityNexus/IdentityTokens-EVM-Frontend#182 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add: GTrekkerĐang mởcheck:passed streams:add
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Koenkk/zigbee-herdsman-converters#13900 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: ui Bug Payload OSS
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
payloadcms/payload#19839 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
jeanibarz/knowledge-base-mcp-server#1291 ·
Maintainer thường phản hồi trong vòng 1 ngày