Test repo at https://github.com/user72356/vite-project
I'm trying to import modules using their absolute path from within the api directory of my app. I'm able to use absolute paths in the front-end portion of the code, for example import hello from "shared/hello";, but not within the api directory.
Doing so results in a Cannot find module error. See https://github.com/user72356/vite-project/blob/main/api/index.ts to see the actual code.
I have limited experience with Vercel and Node.js but I think I may understand what's going on. Since anything in the api directory runs on Node, I suppose shared/hello doesn't map to anything on the filesystem. It only properly maps to something on the web, i.e. example.com/shared/hello. Let me know if I got this right.
How can I make shared/hello be a valid import path on the front-end as well as on the back-end (api folder). Is this even possible?