ITADN

Gracile is incompatible with typescript aliases

#3Closedlschierer 创建于 2024-07-14
L
lschierercommented
I tried to set up aliases in my tsconfig and the vite section of the gracile.config.ts files to make including the documents easier from routes at variable directory depths, and to my surprise, it blew up in my face. I set up a minimal reproduction [here](https://github.com/lschierer/gracile_demos/tree/typescript_aliases). If you check that out and run the command ```pnpm build``` you will see that it produces the error ``` 12:21:37 AM [vite] Pre-transform error: Failed to load url components/testComponent (resolved id: components/testComponent) in /Users/luke/src/aliasesDemo/src/document.ts. Does the file exist? 12:21:37 AM [vite] Error when evaluating SSR module /src/document.ts: failed to import "components/testComponent" |- Error: Cannot find module 'components/testComponent' imported from '/Users/luke/src/aliasesDemo/src/document.ts' .... ``` however ```pnpm tsc``` does not complain. I have tried this from memory of how to do so, then when that didn't work, following the directions at both <https://dev.to/larswaechter/path-aliases-with-typescript-in-nodejs-4353> and <https://www.delasign.com/blog/react-vitejs-typescript-path-alias/> which differ slightly (I tried each way) both from each other and from what I've done in prior projects. Either way, this ought to work and would make maintaining the route files considerably cleaner. Thanks!!
关闭于 2024-08-06 3 条评论