Eleventy serverless .cache directory

I have built an Eleventy serverless template to render previews from Sanity. The template uses Eleventy image to process the images and to create a .cache directory.

In my Eleventy config I have configured Eleventy to copy the .cache directory into the serverless function directory. This works locall using the netlify-cli with netlify dev.

When I deploy the the site to Netlify and attempt to view a preview I get an error.

"error": "json.filter is not a function"

Looking at the function log in Netlify:

Nov 7, 02:54:10 PM: d70f409f ERROR  [11ty] Problem writing Eleventy templates: (more in DEBUG output)
Nov 7, 02:54:10 PM: d70f409f ERROR  [11ty] 1. Having trouble rendering liquid template ./src/pagePreview.liquid (via TemplateContentRenderError)
Nov 7, 02:54:10 PM: d70f409f ERROR  [11ty] 2. ENOENT: no such file or directory, mkdir '.cache', file:/var/task/netlify/functions/serverless/src/_includes/blocks/callout-image.liquid, line:3, col:13 (via RenderError)
Nov 7, 02:54:10 PM: d70f409f ERROR  [11ty] 3. ENOENT: no such file or directory, mkdir '.cache' (via Error)
Nov 7, 02:54:10 PM: d70f409f ERROR  [11ty] 
[11ty] Original error stack trace: Error: ENOENT: no such file or directory, mkdir '.cache'

It seems that the .cache directory is not written into the function for some reason. Any help gratefully received.

AWS Lambda doesn’t provide a writeable directory, so if you’re trying to write something to .cache, it would fail. The only writable directory available is tmp.