Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error from docs: TypeError: Error is not a constructor #99

Closed
cfjedimaster opened this issue Jan 14, 2023 · 2 comments
Closed

Error from docs: TypeError: Error is not a constructor #99

cfjedimaster opened this issue Jan 14, 2023 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@cfjedimaster
Copy link

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.

@zachleat zachleat added the bug Something isn't working label Feb 16, 2023
@zachleat zachleat added this to the WebC v0.9.0 milestone Feb 16, 2023
@zachleat
Copy link
Member

Shipping with WebC v0.9.0

@zachleat
Copy link
Member

(Related to #100)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants