Skip to content

Commit

Permalink
bug #213 Increasing priority of pass to remove before Twig tries to u…
Browse files Browse the repository at this point in the history
…se it (weaverryan)

This PR was merged into the main branch.

Discussion
----------

Increasing priority of pass to remove before Twig tries to use it

Hi!

In 1.17.0, a compiler pass was added to remove the Twig extension that supplies the `stimulus_` functions if StimulusBundle is installed (because it supplies those instead). However, the priority needs to be higher, else (depending on the order your bundles are installed) Twig might try to use the service *first*... and then we remove it. Results in:

> The service "twig" has a dependency on a non-existent service "webpack_encore.twig_stimulus_
> extension". Did you mean this: "webpack_encore.twig_entry_files_extension"?

Cheers!

Commits
-------

49f9302 Increasing priority of pass to remove before Twig tries to use it
  • Loading branch information
weaverryan committed May 29, 2023
2 parents b8ff4a6 + 49f9302 commit 7e3b6f6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/WebpackEncoreBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Symfony\WebpackEncoreBundle;

use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\WebpackEncoreBundle\DependencyInjection\Compiler\RemoveStimulusServicesPass;
Expand All @@ -17,6 +18,7 @@ final class WebpackEncoreBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
$container->addCompilerPass(new RemoveStimulusServicesPass());
// run before TwigEnvironmentPass to remove the twig extension before it's used
$container->addCompilerPass(new RemoveStimulusServicesPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 10);
}
}

0 comments on commit 7e3b6f6

Please sign in to comment.