Skip to content

Improve start error message when importing server code on the client #5469

@lino-levan

Description

@lino-levan

Which project does this relate to?

Start

Describe the bug

When someone imports server code on the client in the current iteration of tanstack start, vite gives a very hard-to-debug error which doesn't expose what file is generating that error. This is a pretty awful issue to debug, especially for projects moving to the RC.

Split off of #5196 (comment), which you should read for more context.

Example error message:

../node_modules/@tanstack/start-server-core/dist/esm/loadVirtualModule.js:5:26:
  5 │       return await import("tanstack-start-manifest:v");
    ╵                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~

Your Example Website or App

#5196 (comment)

Steps to Reproduce the Bug or Issue

import { getRequest } from "@tanstack/react-start/server";

(or similar) on a client-only file

Expected behavior

As a user, I am alright with this erroring, but the error should be actionable instead of blowing up without further guidance. Specifically, I'd really love for the error to point to the offending files.

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.131.7
  • OS: macOS
  • Browser: All
  • Bundler: Vite
  • Bundler Version: 7.1.7

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions