I tried the example shown in the docs for img.webc:
<script webc:type="js" webc:root>
if(!alt) {
throw new Error("oh no you didn't");
}
`<img src="${src}" alt="${alt}">`;
</script>
Using latest Eleventy, latest WebC plugin, and I get:
[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] 1. Having trouble rendering webc template ./index.webc (via TemplateContentRenderError)
[11ty] 2. Error is not a constructor (via TypeError)
[11ty]
[11ty] Original error stack trace: evalmachine.<anonymous>:3
[11ty] throw new Error("oh no you didn't");
[11ty] ^
[11ty]
[11ty] TypeError: Error is not a constructor
[11ty] at evalmachine.<anonymous>:3:8
[11ty] at Script.runInContext (node:vm:139:12)
[11ty] at Script.runInNewContext (node:vm:144:17)
[11ty] at Object.runInNewContext (node:vm:298:38)
[11ty] at Function.evaluateScript (/home/ray/projects/eleventy-demos/webctest2/node_modules/@11ty/webc/src/moduleScript.cjs:62:25)
[11ty] at Object.<anonymous> (file:///home/ray/projects/eleventy-demos/webctest2/node_modules/@11ty/webc/src/ast.js:130:24)
[11ty] at AstSerializer.transformContent (file:///home/ray/projects/eleventy-demos/webctest2/node_modules/@11ty/webc/src/ast.js:802:42)
[11ty] at AstSerializer.compileNode (file:///home/ray/projects/eleventy-demos/webctest2/node_modules/@11ty/webc/src/ast.js:1216:20)
[11ty] at AstSerializer.getChildContent (file:///home/ray/projects/eleventy-demos/webctest2/node_modules/@11ty/webc/src/ast.js:646:40)
[11ty] at AstSerializer.compileNode (file:///home/ray/projects/eleventy-demos/webctest2/node_modules/@11ty/webc/src/ast.js:1365:34)
[11ty] Wrote 0 files in 0.47 seconds (v2.0.0-canary.30)
The error goes away when alt is used of course, but the "right" error isn't being displayed to console.
I tried the example shown in the docs for img.webc:
Using latest Eleventy, latest WebC plugin, and I get:
The error goes away when alt is used of course, but the "right" error isn't being displayed to console.