You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type Definition Colocated with createServerFn Causes: Failed to resolve import "tanstack-start-injected-head-scripts:v" #6480
I have found an issue which is similar in nature to #5709. It seems that a type definition within the same file as as a Server Function definition can cause the "Failed to resolve import "tanstack-start-injected-head-scripts:v" error".
export type CreatePostInput = z.infer<typeof postSchema>;
You can see that this type definition infers a typescript type from a Zod schema, that Zod schema uses an enum imported from another file (PostService.ts). PostService imports the server-only function getCookies. Note, the Zod usage isn't important but I included it as an example of how this might occur in a real-world use case.
The reason I logged this issue instead of dismissing it as a duplicate of #5709 is because I think most devs would assume that the type definitions are stripped by Vite and thus this is a very hard to track down bug.
More generally, and perhaps this isn't the right forum to have this discussion, the dead code elimination strategy described by @schiller-manuel feels like the framework is trying to be too clever. This kind of "magic" frequently leads to the kinds of bugs I'm logging here that are extremely difficult to debug. I think the TanStack team should consider an approach which makes the boundaries of server functions more explicit, even at the cost of additional boilerplate or imposed file/directory structures.
Actual:
An error is surfaced by the Router Dev Tools:
[plugin:vite:import-analysis] Failed to resolve import "tanstack-start-injected-head-scripts:v" from "node_modules/@tanstack/start-server-core/dist/esm/router-manifest.js?v=76cc28db". Does the file exist?
Screenshots or Videos
Platform
Router / Start Version: 1.154.12
OS: Linux
Browser: Chrome
Browser Version: 143.0.7499.193
Bundler: Vite
Bundler Version: 7.3.1
Additional context
Thanks to the team for their hard work on TanStack Start, it's an excellent framework
Reacted by Vito Andareas Manik, Pierre Bourgeois, Andre Felippe and aningdev
Activity
route splitting: types count as a use, never-used imports move to the…