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

Mitigate TemplateContentPrematureUseError case introduced in 4.1.1 #120

Open
2 of 3 tasks
noelforte opened this issue Jan 8, 2025 · 6 comments
Open
2 of 3 tasks
Assignees

Comments

@noelforte
Copy link
Owner

noelforte commented Jan 8, 2025

While addressing #96 for @uncenter I noticed that builds of their site were throwing TemplateContentPrematureUseError. Becuase it wasn't relevant to that issue I closed it as fixed. Since I now suspect this plugin is indeed the cause of the issue, I'm going to investigate further.

Some to-do's:

  • Identify cause
  • Implement test case
  • Implement fix

Relevant notes:

@noelforte noelforte self-assigned this Jan 8, 2025
@uncenter
Copy link

uncenter commented Jan 8, 2025

I was looking at this as well when you brought it up yesterday and did some looking- didn't see any immediate solution. I believe you are correct that the issue is coming from the plugin, as the current Vento rewrite is on the same version of Eleventy as my previous Nunjucks setup, and I wasn't seeing the issue there. Thanks again for looking into this!

@noelforte
Copy link
Owner Author

Related: 11ty/eleventy#2328

@noelforte
Copy link
Owner Author

Also related: 11ty/eleventy#975

@noelforte
Copy link
Owner Author

noelforte commented Jan 8, 2025

Update: Looks like the issue happened when this plugin moved to vento 1.12.14. I'll check the diff and figure out how to navigate around that since it seems like Eleventy really doesn't like other libraries handling its errors as indicated in that first issue I mentioned...although why this causes Eleventy to crash is beyond me...

@noelforte
Copy link
Owner Author

noelforte commented Jan 8, 2025

Ok, it gets weirder...never have I ever haha... @uncenter if you've got any ideas on where to go from here, I'm open to suggestions becuase there's definitely something going on that requires hacking around and I'd rather do it cleanly than patch over wierd issues and I definitely don't want to force Oscar to make Vento bend to Eleventy's conventions, particularly when he decided to write Lume instead... 😅

Apparently this commit that removed extending an error message is the problem. I have no idea why not appending something to the error message has anything to do with accessing the template content but just to make sure...

  1. I cloned uncenter.dev and installed eleventy-plugin-vento@4.1.1
  2. pnpm build
  3. Build fails
  4. Went to node_modules/.pnpm/ventojs@1.12.14/node_modules/ventojs/esm/src/errors.js and on line 14, put this back:
    if (cause) {
      this.message += `(via ${cause.name})\n`;
    }
  5. pnpm build
  6. Build succeeds...?!?! 🤯

If you've got any ideas about where to go next, let me know!

@noelforte
Copy link
Owner Author

Strangely, usage of eleventyImport.collections with the collection name doesn't work here either...

---
eleventyImport:
  collections: ["posts"]
---

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants