Problem with Vercel function with ElysiaJS

Hello there,

I’m currently developing a API service using ElysiaJS. But I’m having trouble to get my code run on Vercel. Here’s what I’ve tried:

  1. By following ElysiaJS’s official guide, which setup bundler to bundle whole code, then output to another folder. This config leads to this:

    In this case, I’ve setup build step and configured an output folder to dist or api. The output is being treated as static assets but not functions.
  2. Use Vercel’s own build system. I removed every build command and output folder. Also package.json’s build script
    Vercel’s build system now automatically identify how to build the project. Results this output structure:

    Note that here Vercel now treated files as function. But Vercel it didn’t bundle it, which makes the function fail. Due to in my code, the main entrypoint references to another file in project.
  3. I built it locally (running bundler on my end), then submit the bundled code inside folder named api to my git repository. Build command and build output folder is not configured.

    This time the function actually work and triggers by going to /api.

TL;DR, problem I’ve encountered:

  • Vercel does not treat .js or .ts file as function if I manually set either build output folder OR build command.
  • If build command does not output build with Build Output API to output the bundle, I assumes, none of the file will be treated as function.

The code is on GitLab (api subfolder): apps/api · main · Wolf Yuan / Where is my YouBike · GitLab

2 Likes

Note that why I didn’t report this to ElysiaJS side is because I don’t think this only applies to it. I think this problem will occur on different framework as well.

2 Likes