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

未关闭
#8,924 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
22/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
react, typescript, vite

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
15.3k
派生
1.9k
平均合并
1 天 5 小时
30 天内合并 PR
46

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TanStack/router 的其他 Issue

查看 TanStack/router 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。