Skip to content
Source
Sign inSign up
TanStack/router

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

Send to my agent
Openglekner(GitHub profile, opens in a new tab) opened this issue 1 comment

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.

  1. I'd like to pick this up. The check is still the same on main in loadViteModuleFromEnvironment.

    I'll make bundled dev environments use the plugin load path like build mode, as in your diff. I'll also add a regression test for a bundled dev environment and a changeset. Let me know if you'd prefer a different way to detect bundled dev.

Sign in to join this conversation.