[BUG] v4 --js front matter compiler crashes on function-scoped const/let: "Export 'X' is not defined in module"

Author: Dile2061Created Aug 29, 2026Updated Aug 29, 2026
Labelsneeds-triage

Operating system

Linux, Ubuntu 24.04 (x64)

Eleventy

4.0.0-alpha.10

Describe the bug

Building a site with Eleventy 4.0.0-alpha.10 fails with a SyntaxError: Export 'cat' is not defined in module and writes zero files. The error is triggered by any ---js front matter block that declares a const/let variable inside a function body (for example inside an eleventyComputed function).

I confirmed this is a compiler regression, not a project issue:

  • The exact same template builds cleanly on stable Eleventy 3.1.6.
  • The error follows the variable name: renaming const cat to const catDesc changes the error to Export 'catDesc' is not defined in module; removing the const moves the error to the next function-local variable (e.g. let tExport 't' is not defined in module).

This suggests the v4 ---js front-matter compiler tries to re-export every variable declaration it scans, including function-scoped ones, producing an invalid ES module.

Reproduction Source Code URL

No response

Screenshots

No response