I have a eleventy Node project, which renders HTML from a JSON file.
Currently, I run this locally using npm run
(which runs the eleventy CLI)
Here's the workflow I have in my head:
Conceptually, I feel like this would be a standard FaaS use case.
Practically, I stumble over the fact that the Node.js-Lambda runtime always expects an explicit function handler to be invoked. It seems Eleventy does not provide a standard way to be invoked from code (or I have not discovered this yet).
I found that I could build my package into a Docker container and run the npm run
as Entrypoint. This would surely work, but seems unnecessary, since the Lambda-provided Node.js runtimes should be capable of running my npm build command if I put my packages in the deployment artifact.
Do I have a knot in my brain? Anything I'm overlooking? Would be happy about any input.
I'm not sure this is supported as I don't see it documented, but I looked at the unit tests for Eleventy and saw many examples of this (https://github.com/11ty/eleventy/tree/master/test). I tried the following and it worked. Note that init an write are both async and I do NOT properly await them, I was just trying to get a simple example:
const Eleventy = require('@11ty/eleventy');
const elev = new Eleventy('./input', './output');
elev.init();
elev.write();
console.log('done');