Unused `export *` re-export is kept in the entry chunk

Đang mở
#8,924 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
22/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
react, typescript, vite
Lĩnh vực
build-system, frontend

Hướng nghiên cứu

Start with the repro shape in the issue: src/ui/index.ts re-exports Grid via export *, and src/console/LazyGrid.tsx loads it with import("./Grid"). Reproduce by building a minimal Start app and grepping the entry chunk for the marker string. Done means heavy is absent from the entry chunk, which needs understanding of how the TanStack Start plugin builds the module graph on top of Rolldown.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Unused export * re-export is kept in the entry chunk under TanStack Start

Versions

  • @tanstack/react-start 1.169.5
  • @tanstack/react-router 1.170.46
  • vite 8.3.8 (Rolldown 1.2.19)
  • @vitejs/plugin-react 6.3.0
  • React 19.3.1

Minimal structure

// src/console/Grid.tsx
import { heavy } from "./heavy" // ~12 kB of marker code
export function Grid() { return <div>{heavy("x")}</div> }

// src/ui/index.ts
export * from "../console/Grid"
export { other } from "./other"

// src/routes/__root.tsx
import { other } from "../ui" // only `other` is used
export const Route = createRootRoute({ component: () => <><div>{other}</div><Outlet /></> })

// src/console/LazyGrid.tsx
const Grid = lazy(() => import("./Grid").then((m) => ({ default: m.Grid })))
export function LazyGrid() { return <Suspense fallback={null}><Grid /></Suspense> }

// routes under /app import LazyGrid only

Expected

heavy is not reachable from the entry: Grid is only reached through the
lazy import("./Grid"), and the export * re-export in src/ui/index.ts is
unused. heavy should stay in the lazy Grid chunk (or be dropped entirely).

Actual

heavy is emitted into dist/client/assets/index-*.js (the entry chunk) and
is therefore preloaded by every route.

Verification

grep -l HEAVY_MARKER dist/client/assets/*.js
# actual: dist/client/assets/index-*.js

The same structure built with vanilla Vite (no Start) drops HEAVY_MARKER
entirely, so this appears to be the Start plugin's module/chunk graph, not
Rolldown's general tree-shaking.

Why it matters

In a large Start app this is ~139 kB of @tanstack/table-core source plus
~74 kB of @tanstack/virtual-core in the entry, even though the only importer
is a lazily loaded DataGrid; the storefront and login preload it and the
route-group bundle budgets pay for it.

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

Mở trong Codespaces

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.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TanStack/router

Tất cả issue của TanStack/router

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.