I am trying to deploy my serverless function. My deployment went through without any problem. However, I am encountering issues where AWS lambda console is looking for .mjs extension but the built code is in .js. I have to then manually update the extension for my deployment to work which defeats the purpose. I tried both the outExtension and the outFile config but no luck.
Here's my serverless.yml config:
...
build:
esbuild:
bundle: true
minify: false
external:
- "uuid"
exclude: "*"
format: esm
outExtension:
".js": ".mjs"
plugins:
- serverless-offline
...
This is the basic code that I want to deploy:
import { v4 as uuidv4 } from "uuid";
export const hello: any = async (event: any) => {
return {
statusCode: 200,
body: JSON.stringify({
id: uuidv4(),
message: "Go Serverless v4! Your function executed successfully!",
}),
};
};
The compiled outcome is as follow:
|--handler.js // <=== AWS Lambda expecting handler.mjs
|--handler.js.map