Cannot load templates dynamically
Hi,
I've created a simple repo to enable quick reference and debugging for the issue: https://github.com/kalinchernev/twing The issue comes in a setup of older twing versions which we haven't found a way to upgrade yet. But it still works with loading templates in a normal way.
The issue we face comes from our attempt to load templates dynamically after variables concatenation. I spent a few hours today with the attempt of upgrading only the loader, but didn't manage to reach a working state. I also spent additional time trying to debug the caching maps and configurations, but didn't manage to find the issue.
In an attempt to to have the following, there are no issues
{% include '@ecl-twig/ec-component-button/ecl-button.html.twig' only %}
However, trying the following yields an error:
{% include '@ecl-twig/ec-component-' ~ component ~ '/ecl-' ~ component ~ '.html.twig' only %}
The error message
Template "@ecl-twig/ec-component-button/ecl-button.html.twig" is not defined in "__HASHED__469502d920d68a41fe7c1732b28589a1319aca337beed836815c2bbfb89f6e0c" at line 1.
TwingErrorLoader: Template "@ecl-twig/ec-component-button/ecl-button.html.twig" is not defined in "__HASHED__469502d920d68a41fe7c1732b28589a1319aca337beed836815c2bbfb89f6e0c" at line 1.
at TwingLoaderChain.getSourceContext (http://localhost:34359/vendors~main.4b1d58f3fa2fe7f97087.bundle.js:129342:15)
at TwingEnvironmentBrowser.loadTemplate (http://localhost:34359/vendors~main.4b1d58f3fa2fe7f97087.bundle.js:122430:43)
at __HASHED__469502d920d68a41fe7c1732b28589a1319aca337beed836815c2bbfb89f6e0c.loadTemplate (http://localhost:34359/vendors~main.4b1d58f3fa2fe7f97087.bundle.js:136124:29)
at __HASHED__469502d920d68a41fe7c1732b28589a1319aca337beed836815c2bbfb89f6e0c.doDisplay (http://localhost:34359/main.4b1d58f3fa2fe7f97087.bundle.js:372:18)
at __HASHED__469502d920d68a41fe7c1732b28589a1319aca337beed836815c2bbfb89f6e0c.displayWithErrorHandling (http://localhost:34359/vendors~main.4b1d58f3fa2fe7f97087.bundle.js:136184:18)
at __HASHED__469502d920d68a41fe7c1732b28589a1319aca337beed836815c2bbfb89f6e0c.display (http://localhost:34359/vendors~main.4b1d58f3fa2fe7f97087.bundle.js:136163:14)
at __HASHED__469502d920d68a41fe7c1732b28589a1319aca337beed836815c2bbfb89f6e0c.render (http://localhost:34359/vendors~main.4b1d58f3fa2fe7f97087.bundle.js:136169:18)
at push../src/ec/packages/ec-component-layout/ecl-layout.html.twig.module.exports (http://localhost:34359/main.4b1d58f3fa2fe7f97087.bundle.js:402:21)
at Default (http://localhost:34359/main.4b1d58f3fa2fe7f97087.bundle.js:425:70)
at finalStoryFn (http://localhost:34359/vendors~main.4b1d58f3fa2fe7f97087.bundle.js:4615:32)
You can see the error reproduced in the repo above (yarn install + yarn start)
What are your suggestions for tackling this issue? Do we need to load templates more granularity somehow with a different loader interface or rather debug the webpack/babel/storybook chain?
Thanks in advance for your advice!