TanStack / TanStack/router

start-compiler-plugin fails to lazy-load dependencies with Vite bundledDev

Open Beginner friendly
#8,407 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
15.1k
Forks
1.9k
Avg merge
1d 20h
Merged PRs (30d)
143

Description

Which project does this relate to?

Start

Describe the bug

With Vite experimental.bundledDev, the Start compiler can fail while lazily inspecting a server-function dependency such as Zod.

Bundled environments still report environment.mode === "dev", so loadViteModuleFromEnvironment calls environment.transformRequest(). That path does not load arbitrary modules into Rolldown bundled dev. The compiler cache stays empty and lazy bundling fails with could not load module info.

Steps to reproduce
  1. Use Vite 8.3.0 and @tanstack/start-plugin-core 1.171.39.
  2. Enable experimental: { bundledDev: true }.
  3. Add a lazy route with a createServerFn input validator using Zod.
  4. Open the route.

The lazy bundle fails while loading zod/index.js.

Expected behavior

Bundled dev should use the plugin load hook, like build mode does.

This change fixes the issue locally:

-if (environment.mode === "build") {
+if (environment.mode === "build" || environment.config.isBundled) {

Tested with Vite 8.3.0, Rolldown 1.2.6, React Start 1.168.49, and start-plugin-core 1.171.39.

Related bundled-dev reports: #7488 and #8062, but those cover CSS and HMR rather than compiler dependency loading.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at loadViteModuleFromEnvironment in the Start compiler plugin and reproduce with Vite 8.3.0 using experimental.bundledDev and the lazy Zod validator setup described. Verify that bundled dev uses the plugin load hook and that opening the lazy route no longer fails with “could not load module info” for zod/index.js.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vite
Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.