-
Notifications
You must be signed in to change notification settings - Fork 0
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
Updating to 4.1.0 causes build failure #96
Comments
Will investigate. Apologies for all the weird errors! Hopefully we'll get to something stable eventually 😅 |
No worries ahah, this plugin is amazing and I am so glad I switched to Vento - happy to help debug whatever and hopefully get other 11ty users to switch over as well :) |
Could you try running your build with the environment variable You could take the transformed function and use it to trace where Output should be similar to something like this: Eleventy:Vento Getting template function for `page.vto` +20ms
Eleventy:Vento:Cache Cache MISS for `page.vto`, compiled new template:
Eleventy:Vento:Cache Use Vento cache: false
Eleventy:Vento:Cache
Eleventy:Vento:Cache async function (it) {
Eleventy:Vento:Cache let __pos = 0;
Eleventy:Vento:Cache try {
Eleventy:Vento:Cache it = Object.assign({}, __defaults, it);
Eleventy:Vento:Cache const __exports = { content: "" };
Eleventy:Vento:Cache __exports.content += "<head>\n\t";
Eleventy:Vento:Cache __pos = 8;
Eleventy:Vento:Cache for (let [name, content] of __env.utils.toIterator(it.meta, true)) {
Eleventy:Vento:Cache __exports.content += "\n\t\t<meta name=\"";
Eleventy:Vento:Cache __pos = 54;
Eleventy:Vento:Cache __exports.content += name ?? "";
Eleventy:Vento:Cache __exports.content += "\" content=\"";
Eleventy:Vento:Cache __pos = 75;
Eleventy:Vento:Cache __exports.content += content ?? "";
Eleventy:Vento:Cache __exports.content += "\"> \n\t";
Eleventy:Vento:Cache }
Eleventy:Vento:Cache __exports.content += "\n</head>\n\n<body>\n\t";
Eleventy:Vento:Cache __pos = 121;
Eleventy:Vento:Cache {
Eleventy:Vento:Cache const __result = await __env.utils.eleventyFunctions.shortcodes.testShortcode.call({
Eleventy:Vento:Cache page: it.page,
Eleventy:Vento:Cache eleventy: it.eleventy
Eleventy:Vento:Cache }, "arg1", "arg2");
Eleventy:Vento:Cache __exports.content += __result;
Eleventy:Vento:Cache }
Eleventy:Vento:Cache __exports.content += "\n\n\t";
Eleventy:Vento:Cache __pos = 158;
Eleventy:Vento:Cache __exports.content += await __env.filters.test.call({
Eleventy:Vento:Cache data: it,
Eleventy:Vento:Cache env: __env
Eleventy:Vento:Cache }, "{{ 2 + 2 }}") ?? "";
Eleventy:Vento:Cache __exports.content += "\n</body>\n\n";
Eleventy:Vento:Cache
Eleventy:Vento:Cache return __exports;
Eleventy:Vento:Cache } catch (cause) {
Eleventy:Vento:Cache const template = __env.cache.get(__file);
Eleventy:Vento:Cache throw new __err(__file, template?.source, __pos, cause);
Eleventy:Vento:Cache }
Eleventy:Vento:Cache } +0ms
Eleventy:Vento:Render Rendering `page.vto` +0ms |
If it helps, I just put 4.1.1-beta.0 (with I'm not super familiar with Vento's |
|
Thinking out loud: Given the file is empty, whatever's in let { PostList: PostList } = await __env.run("../components/postlist.vto", {
...it
}, __file) This is where this plugin and Vento differ in implementation. This plugin uses Vento's However, when Vento runs a template internally, it uses Couple ways we could proceed to identify the cause of the issue:
With 4.1.1-beta.0, the changes from ventojs/vento#89 are in there, but as you've already seen, this: [11ty] Problem writing Eleventy templates:
[11ty] 1. Having trouble rendering vto template ./src/posts/index.vto (via TemplateContentRenderError)
[11ty] 2. Error in template src/posts/index.vto:1:1
[11ty]
[11ty] <empty file>
[11ty]
[11ty] (via TemplateError) (via TemplateError) is even more vague than this: 20:03:44.311 | [11ty] Problem writing Eleventy templates:
-- | --
20:03:44.311 | [11ty] 1. Having trouble rendering vto template ./src/posts/index.vto (via TemplateContentRenderError)
20:03:44.312 | [11ty] 2. [22:13-22:18]: Await is only valid in async functions (via SyntaxError) Eleventy doesn't correctly report the entire error chain, including Errors with a Think that just about covers everything for now. Unfortunately, I don't have time in the next couple days to work on this but if you want to raise any PRs I can look and review. Otherwise, I'll get back to this when I have a moment. |
Oh! One other thing: |
@uncenter I was able to ID this for you by cloning uncenter.dev and fiddling with the code. That, combined with the changes now in Vento v1.12.13 and Eleventy 4.0.1-alpha.1 yielded this error message: [11ty] Problem writing Eleventy templates:
[11ty] 1. Having trouble rendering vto template ./src/tags.vto (via TemplateContentRenderError)
[11ty] 2. Error in template src/tags.vto:1:2
[11ty]
[11ty] <empty file>
[11ty]
[11ty] (via TemplateError) (via TemplateError)
[11ty] 3. Error in template src/components/postlist.vto:7:92
[11ty]
[11ty] <h2 class="font-semibold mx-0 my-0 text-xl leading-8" style="view-transition-name: post-{{ post.data.title |> slugify }}">
[11ty]
[11ty] (via TransformError) (via TemplateError)
[11ty] 4. [meriyah] [22:13-22:18]: Await is only valid in async functions while parsing compiled template function:
[11ty]
[11ty] 22 __output += (await __env.filters.slugify.call({data:it,env:__env}, post.data.title)) ?? "";
[11ty] ^ (via TransformError)
[11ty]
[11ty] Original error stack trace: TransformError: [meriyah] [22:13-22:18]: Await is only valid in async functions while parsing compiled template function:
[11ty]
[11ty] 22 __output += (await __env.filters.slugify.call({data:it,env:__env}, post.data.title)) ?? "";
[11ty] ^
[11ty] at transformTemplateCode (file:///Users/noel/Developer/projects/tools/eleventy-plugin-vento/node_modules/.pnpm/[email protected]/node_modules/ventojs/esm/src/transformer.js:114:15)
[11ty] at Environment.compile (file:///Users/noel/Developer/projects/tools/eleventy-plugin-vento/node_modules/.pnpm/[email protected]/node_modules/ventojs/esm/src/environment.js:48:24)
[11ty] at Environment.load (file:///Users/noel/Developer/projects/tools/eleventy-plugin-vento/node_modules/.pnpm/[email protected]/node_modules/ventojs/esm/src/environment.js:99:35)
[11ty] at async Environment.run (file:///Users/noel/Developer/projects/tools/eleventy-plugin-vento/node_modules/.pnpm/[email protected]/node_modules/ventojs/esm/src/environment.js:19:26)
[11ty] at async eval (eval at compile (file:///Users/noel/Developer/projects/tools/eleventy-plugin-vento/node_modules/.pnpm/[email protected]/node_modules/ventojs/esm/src/environment.js:57:29), <anonymous>:10:28)
[11ty] at async renderVentoTemplate (file:///Users/noel/Developer/projects/tools/eleventy-plugin-vento/dist/plugin.js:122:23)
[11ty] at async Object.<anonymous> (file:///Users/noel/Developer/projects/tools/eleventy-plugin-vento/dist/plugin.js:224:30)
[11ty] at async Template._render (file:///Users/noel/Developer/projects/external/uncenter.dev/node_modules/.pnpm/@[email protected]/node_modules/@11ty/eleventy/src/TemplateContent.js:586:19)
[11ty] at async file:///Users/noel/Developer/projects/external/uncenter.dev/node_modules/.pnpm/@[email protected]/node_modules/@11ty/eleventy/src/TemplateMap.js:555:8
[11ty] at async file:///Users/noel/Developer/projects/external/uncenter.dev/node_modules/.pnpm/[email protected]/node_modules/p-map/index.js:121:20
[11ty] Copied 13 Wrote 0 files in 3.40 seconds (v3.0.1-alpha.1)
ELIFECYCLE Command failed with exit code 1. At last, we have a good trace of the error chain. This plugin wraps all Eleventy filters in async functions, so this: {{ post.data.title |> slugify }} becomes this: __output += (await __env.filters.slugify.call({data:it,env:__env}, post.data.title)) ?? ""; Because
- {{ export function PostList(posts) }}
+ {{ export async function PostList(posts) }}
If there's another way I haven't mentioned that you think would be better used to solve this, let me know! |
Ok, progress. Unfortunately, it seems that even when It's a shame, since Vento has the ability to identify if a filter is an instance of I would rather not coerce all filters to be sync-by-default and then have to force |
Sorry for the delayed response, thank you for taking the time to look into it further! I wonder if Eleventy could add methods for extracting only synchronous or asynchronous filters? Such as |
Perhaps? I dig a bit more digging to confirm I understood As I understand it, if
Behavior shouldn't change, it just means that if you use async filters in your Eleventy config, you'll have to remember to use |
But I thought you said all filters are async because of some changes made recently? I don't think |
Steps to reproduce
The build for this dependency update PR on my website is failing: uncenter/uncenter.dev#234.
I can't even see what is async about https://github.com/uncenter/uncenter.dev/blob/main/src/posts/index.vto (which just wraps the https://github.com/uncenter/uncenter.dev/blob/main/src/components/postlist.vto component, which also doesn't appear to be async). Is this an issue with Vento 1.12.12 that was bumped in this update? I don't see anything about it in the upstream issues or release notes for the recent 1.12.13 release.
Expected behavior
Successful build, as it is with v4.0.1.
Actual behavior
Got error as above.
Plugin version
4.1.0
Eleventy version
3.0.0
Reduced Test Case URL
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: