pattern-lab / patternlab-node

The Node version of Pattern Lab
http://patternlab.io
MIT License
2.05k stars 405 forks source link

Is Pattern twig-php is broken and doesn't render any patterns? #1505

Closed sridhar614 closed 6 months ago

sridhar614 commented 6 months ago

Hi I am running pattern lab node with version 18, with twig php support on Drupal 10 project, I don't see .html files are creating under public directory and seeing below errors

Warning: Undefined array key "data" in /Users/sridhar/pattern_twig/node_modules/@basalt/twig-renderer/dist/server--async.php on line 115
PHP TwigRenderer Error: The response callback is expected to resolve with an object implementing Psr\Http\Message\ResponseInterface, but rejected with "TypeError" instead.

I am using Pattern Lab Node v6.1 on Mac, with Node v18, using a Gulp | Grunt | Vanilla | Custom Edition.

Expected Behavior

Pattern lab should render the patterns with twig php engine

Actual Behavior

Patterns doesn't render and throws below error

Warning: Undefined array key "data" in /Users/sridhar/pattern_twig/node_modules/@basalt/twig-renderer/dist/server--async.php on line 115
PHP TwigRenderer Error: The response callback is expected to resolve with an object implementing Psr\Http\Message\ResponseInterface, but rejected with "TypeError" instead.
Steps to Reproduce

npm create pattern-lab select twig-php with demo patterns npm run start

heshanlk commented 6 months ago

The problem starts from one of the dependency libraries @basalt/twig-renderer. Upgrading to version 3.0 of this library is causing issues with version 6.1.0 of Pattern Lab. As a temporary solution, I can suggest reverting to an older version of @basalt/twig-renderer.

Follow the steps below to implement this workaround.

Run

npm i @pattern-lab/engine-twig-php@6.0.1 This will downgrade the @pattern-lab/engine-twig-php as well as use the 2.x version of the @basalt/twig-renderer package.

npm start

sridhar614 commented 6 months ago

Thanks @heshanlk that helped to resolve the issue