11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
https://www.11ty.dev/
MIT License
17.32k stars 495 forks source link

syntax.split is not a function #2571

Closed zachleat closed 1 year ago

zachleat commented 2 years ago

Build-time error (not runtime):

[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] 1. Having trouble rendering liquid template ./src/tests/liquid-md.md (via TemplateContentRenderError)
[11ty] 2. syntax.split is not a function, file:./src/tests/liquid-md.md, line:8, col:35 (via RenderError)
[11ty] 3. syntax.split is not a function (via TypeError)
[11ty] 
[11ty] Original error stack trace: TypeError: syntax.split is not a function
[11ty]     at Object.renderAsLiquid (/Users/zachleat/Code/demo-eleventy-edge/node_modules/@11ty/eleventy/src/Plugins/EdgePlugin.js:119:26)
[11ty]     at Object.render (/Users/zachleat/Code/demo-eleventy-edge/node_modules/@11ty/eleventy/src/Plugins/Edge/LiquidEdge.js:43:23)
[11ty]     at Tag.<anonymous> (/Users/zachleat/Code/demo-eleventy-edge/node_modules/liquidjs/dist/liquid.node.cjs.js:4454:47)
[11ty]     at step (/Users/zachleat/Code/demo-eleventy-edge/node_modules/liquidjs/dist/liquid.node.cjs.js:88:23)
[11ty]     at Object.next (/Users/zachleat/Code/demo-eleventy-edge/node_modules/liquidjs/dist/liquid.node.cjs.js:69:53)
[11ty]     at /Users/zachleat/Code/demo-eleventy-edge/node_modules/liquidjs/dist/liquid.node.cjs.js:1599:38
[11ty]     at step (/Users/zachleat/Code/demo-eleventy-edge/node_modules/liquidjs/dist/liquid.node.cjs.js:88:23)
[11ty]     at Object.next (/Users/zachleat/Code/demo-eleventy-edge/node_modules/liquidjs/dist/liquid.node.cjs.js:69:53)
[11ty]     at fulfilled (/Users/zachleat/Code/demo-eleventy-edge/node_modules/liquidjs/dist/liquid.node.cjs.js:59:58)
[11ty] Copied 5 files / Wrote 0 files in 0.31 seconds (v2.0.0-canary.15)

Pinned this down to a regression in liquidjs 9.42.0, canary-16 will be pinned to 9.41.0.

To workaround this locally, just add "liquidjs": "9.41.0", to your package.json under dependencies.

zachleat commented 2 years ago

cc @harttle I was able to narrow this down to an extra token being returned here (which resulted in extra internal-to-liquid arguments):

https://github.com/11ty/eleventy/blob/e9ca971210fa06efd2af3a7931ef368dcb085a79/src/Plugins/Edge/LiquidEdge.js#L13-L19

zachleat commented 2 years ago

Specifically this was being returned as a token when I don’t think it should be?

{
    next: [Function (anonymous)],
    throw: [Function (anonymous)],
    return: [Function (anonymous)],
    [Symbol(Symbol.iterator)]: [Function (anonymous)]
  }
zachleat commented 2 years ago

2.0.0-canary.16 has shipped with liquidjs pinned to 9.41.0

harttle commented 2 years ago

Specifically this was being returned as a token when I don’t think it should be?

No, it shouldn't. I can't see how it can be. Do you have a tagToken.args value (used to init the Tokenizer) to repro? Maybe it's broken elsewhere, it'll help if we have a runable snippet.

https://github.com/11ty/eleventy/blob/e9ca971210fa06efd2af3a7931ef368dcb085a79/src/Plugins/Edge/LiquidEdge.js#L11-L19

zachleat commented 1 year ago

I got this fixed up! I wasn’t evaluating my tokens correctly in the render function.

zachleat commented 1 year ago

Shipping with 2.0.0-canary.19