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

Relax circular dependency errors #138

Closed
niklasgrewe opened this issue Mar 23, 2023 · 3 comments
Closed

Relax circular dependency errors #138

niklasgrewe opened this issue Mar 23, 2023 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@niklasgrewe
Copy link

I tried to use this example from the docs:

<!-- index.webc -->
<img src="my-image.jpeg" alt="An excited Zach is trying to finish this documentation">
<!-- _includes/components/img.webc -->
<script webc:type="js" webc:root>
if(!alt) {
   throw new Error("oh no you didn’t");
}
`<img src="${src}" alt="${alt}">`;
</script>

when i try to serve, i get the following error:

1. Having trouble rendering webc template ./index.webc (via TemplateContentRenderError)
2. Circular dependency error: You cannot use <img> inside the definition for ./_includes/components/img.webc (via Error)
Original error stack trace: Error: Circular dependency error: You cannot use <img> inside the definition for ./_includes/components/img.webc

Is this a bug? I am using the latest versions.

@zachleat zachleat self-assigned this Mar 24, 2023
@zachleat zachleat added the bug Something isn't working label Mar 24, 2023
@zachleat
Copy link
Member

I think the docs should say:

<script webc:type="js">
if(!alt) {
   throw new Error("oh no you didn’t");
}
`<img src="${src}" alt="${alt}" webc:root>`;
</script>

That said, I think it’s time to relax the aggressiveness of the error a bit!

I think we should change the behavior so that using <img> instead of img.webc should allow it and just use the tag plain instead of re-resolving with WebC.

@zachleat zachleat added this to the WebC v0.9.4 milestone Mar 24, 2023
@zachleat
Copy link
Member

Also related to #107

@zachleat
Copy link
Member

Shipping with 0.10.0

@zachleat zachleat changed the title Circular dependency error Relax circular dependency errors Mar 24, 2023
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