NightlyCommit / twing-loader

*** This project is now hosted in GitLab ***
https://gitlab.com/nightlycommit/twing-loader
12 stars 13 forks source link

Compatibility with Twing@5 #24

Closed hason closed 3 years ago

hason commented 4 years ago

Fixes #21, but for Twing@5.

Test fails due to https://github.com/NightlyCommit/twing/pull/513

hason commented 4 years ago

Test fails due to https://github.com/NightlyCommit/twing/pull/519.

christianwiedemann commented 3 years ago

Is there a way I can help to push this PR forward? Think it is nearly done.

JohnAlbin commented 3 years ago

It took some work, but I managed to test this PR.

It needs some significant work.

  1. A webpack loader is supposed to be a synchronous function that, if it requires async transforms, calls webpack's callback when it is finished transforming the loaded resource. Instead, this PR's twing-loader returns a Promise that then calls webpack's callback. This is unnecessary and aggravates point 2.
  2. The compile and render functions in Twing are synchronous. The loadTemplate function is async. Fortunately, webpack has already loaded the Twig template for us; it is the source that is given to the twing-loader. But this PR wraps all the Twing code in Promises so that we can't perform the transform synchronously.

I've got some non-working code that starts to fix these issues, but GitHub really makes it hard to collaborate on one issue. You can find it here: https://github.com/hason-contributions/twing-loader/pull/1

ericmorand commented 3 years ago

Replaced by #29