Closed mikestopcontinues closed 10 months ago
Currently, endpoints (beside edge endpoints) are always compiled to CJS, because that was the only thing that Vercel was able to run at the time.
I failed to stumble upon a use case that required me to have to implement an ESM target, and looking at your error message, I'm still not sure.
What is your "first step in the build process" exactly? If this first steps creates .cjs
instead (you could try just renaming those files manually), does it work, or do you have other issues?
Sorry, I just realized I misinterpreted "first step." I tried a few variations where my old entry was still building.
Vercel (on Node 18) expects .js to be esm with package type "module". I'm sure I can rename the output files to cjs, but I also need to update .vc-config.json.
What I'm wondering about is why your examples are all "module" but presumably work fine. Are they deployed to an earlier version of node?
The demo page is deployed with node@18
, but it uses Vike, which generates esm+cjs files. Are you using Vike? If not perhaps I need to make sure that the compilation steps generates .cjs
files.
Here is the full log of the last deploy if it can be of any help pinpointing the difference:
I tried just the rename and update to .vc-config.json
. But I received the same error from Vercel. Since I can't see the output, it makes me wonder if they rename the file back to .js
or some such. I need a stopgap to a service outage, so I need to look elsewhere.
Anyway, thanks for your help.
My tsconfig.json and vite.config.ts seems to be configured identically to the example repos. The first step in the build process produces ESM. However, my api handler gets compiled to CJS. When Vercel tries to run the function, it errors:
Are there any known culprits to this behavior?