Full Stack Components no longer possible with Vite #8283
-
In the latest Remix v2.4.0, a breaking change was introduced to the vite plugin (which is totally fair considering it's unstable) that route modules can no longer export arbitrary user-defined exports (See here: https://remix.run/docs/en/main/future/vite#strict-route-exports). While this definitely improves stability, this seems like it might break one of the best features about Remix which was the ability to co-locate individual UI components with their route actions (See this article by Kent Dodds: https://www.epicweb.dev/full-stack-components). I use this in my own workflow but I haven't tried out the vite plugin completely myself yet so I'm going based off the patch notes here. What is an alternative for people who still want to use this workflow and have type safety? Is it good enough that you move your component code to your components directory and do the following? import type {loader} from "~/routes/resource/thing";
export default function MyComponent(props) {
const fetcher = useFetcher<typeof loader>()
...componentCode
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
You could move the code to outside routes and then re-export the loader and action from an actual route. |
Beta Was this translation helpful? Give feedback.
-
Looks like there's a PR to remove this restriction now #8420 |
Beta Was this translation helpful? Give feedback.
You could move the code to outside routes and then re-export the loader and action from an actual route.