I can’t find the (explicit) answer to what I would have thought would be a very common question: can I use netlify dev with unbundled functions and also use GitHub-based CD without having to have a netlify-lambda build step (or indeed any build step for the functions)?
The Netlify docs and the netlify-lambda readme both say that you can use netlify dev and unbundled function scripts as of CLI v2.7. That’s great, but I’m not using the CLI - I’m using Git-based CD. (Actually I was using the CLI to deploy and indeed this did work perfectly, but I moved to Git-based CD and now the functions fail to build due to not having the deps installed.)
FWIW I added the functions based on netlify functions:create with one of the FaunaDB starters (which I then customised to work how I want), and it gave me a new dir for the function with a function-name.js file, package.json and a package-lock.json and a node_modules dir (function best practice, yay). node_modules is obviously not committed to Git so I think this is why the build failed. This suggests to me that maaaybe ZISI is trying to do its work on deploy to do the bundling for me (yay), but not finding the packages to zip - i.e. it only zips and ships, but doesn’t first install deps with npm install for some reason. But I can’t say that with any real certainty, just a hunch.
However, I’m surprised that code that is generated by netlify functions:create, supported just fine by netlify dev and netlify deploy just fails when used with the CD. As such, I figured I’d check whether there’s something I’m doing wrong.
I have previously (before netlify dev was out, or at least properly out) used netlify-lambda to do local dev as well as including it in the build command for CD deployments. That works, but I’d be surprised if I still have to do this now I’m not in actual need of netlify-lambda locally.
Am I missing something?
Also, if I do now need to use netlify-lambda to bundle my unbundled (but otherwise not in need of transpilation) functions, do I need to change it to use the single functions dir with file-per-function entrypoint? What about the best practice of multiple directories each with their own package.json? I’m confused. It seems like the “new” netlify dev unbundled functions stuff and the “old” netlify-lambda ways are kinda working against each other. But it seems like netlify dev unbundled functions is made to work with CLI deploys only, and for CD deploys you need to have a build script to make these massive single JS files (be that netlify-lambda or your own custom way of doing the same I guess.
Any pointers?
Thanks.