Remix + Vite logging error when importing from .server file

81 Views Asked by At

I have a file named validation.server.jsx that i use to export a schema validation function.

As the name indicate it is a .server file with code to run exclusively server-side.

I than use the function exported the refered file to validate data inside the action of my route.jsx.

Now with Vite, Im getting the error below just by importing the function from the validation.server.jsx file into my app/routes/admin/route.jsx.

import { validateSchema } from "../../lib/validation.server"

By making this import I get the error or any import from a .server file into a route.jsx file i get the error:

Pre-transform error: Server-only module referenced by client
    '../../lib/validation.server' imported by route 'app/routes/admin/route.jsx'
  Remix automatically removes server-code from these exports:
    `loader`, `action`, `headers`

Remix version 2.8.1

0

There are 0 best solutions below