I have a relatively simple setup that essentially bundles some source code and outputs to dist using esbuild. This works and I can see it in the output tab of my function.
However, when I attempt to import it from my serverless function in the api folder, i.e. “api/x.ts”, it cannot find the module.
The code itself is very simple for x.ts
export { GET } from "../handler.js"
with the output directory structure being:
api/
├─ x.js
├─ middleware
handler.js
middleware
This is running on node 22.x. I cannot determine why I cannot import handler.js from my serverless function. I’ve added “includeFiles”: “handler.js” to my vercel.json.
The actual error is:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module ‘/var/task/handler.js’ imported from /var/task/api/x.js
Thank you