I am trying to use netlify-lambda
to build my netlify functions so that I can write them in typescript. The issue I’m running into, though, is that netlify cli
scaffolds new functions into subdirectories which netlify-lambda
doesn’t seem able to pick up on.
For example, if I use the CLI to create two functions, the output looks like this:
serverless/
my-function/
my-function.ts
my-other-function/
my-other-function.ts
This is my netlify.toml
[build]
command = "yarn build"
functions = "build-serverless"
publish = "build"
[[redirects]]
from = "api/*"
to = "/.netlify/functions/:splat"
status = 200
This is what I have under scripts
in package.json
"scripts": {
"start": "run-p start:**",
"start:app": "react-scripts start",
"start:lambda": "netlify-lambda serve serverless",
"build": "run-p build:**",
"build:app": "react-scripts build",
"build:lambda": "netlify-lambda build serverless",
...etc
}
However, when I run yarn build:lambda
, this is the output
❯ yarn build:lambda
yarn run v1.7.0
$ netlify-lambda build serverless-copy/functions
netlify-lambda: Building functions
---Start netlify-lambda notification---
WARNING: No valid single functions files (ending in .mjs, .js or .ts) were found.
This could be because you have nested them in a folder.
If this is expected (e.g. you have a zipped function built somewhere else), you may ignore this.
---End netlify-lambda notification---
Furthermore, if I update the build:lambda
script to:
"build:lambda": "netlify-lambda build serverless/*"
then it will build the function in the first directory (my-function.ts
builds to build-serverless/my-function.js
), but none of the others get built.
Is there a way to get netlify cli and netlify-lambda to work together?