Skip to content

Import protection doesn't work with TS path mapping #6770

@wand3r

Description

@wand3r

Which project does this relate to?

Start

Describe the bug

Import protection based on file patterns doesn't seem to work with TypeScript path mapping. In reproduction repo I rely on default *.server.* pattern but it seems to not work with user defined patterns too.

What I noticed it that the order of plugins in vite.config.ts matters here. When vite-tsconfig-paths is before tanstackStart plugin protection doesn't work. When I move vite-tsconfig-paths after tanstackStart it seems to work correctly.

In docs and in Create CLI vite-tsconfig-paths plugin is always before tanstackStart plugin so I assume that that it isn't expected behaviour.

Additionally behaviour was slightly different between mock and error behavior option:

  • with mock I got cryptic error message
  • with error I got no errors

Your Example Website or App

https://github.com/wand3r/tanstack-start-import-protection

Steps to Reproduce the Bug or Issue

Repo was created with npm create @tanstack/start@latest. The only changes are in the second commit where I added get-sercret-env.server.ts file with getSecretEnv function and use it in /routes/index.tsx.

  1. Run dev server with npm run dev.
  2. Go to localhost:3000.

Expected behavior

Error page should be displayed with violation traces. Instead standard page is displayed and function from .server.ts file is executed on the client (console.log is printed).

Screenshots or Videos

No response

Platform

  • Start Version: 1.132.0
  • OS: macOS
  • Browser: Chrome
  • Browser Version: 145
  • 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