Skip to content

Commit ba8dcad

Browse files
Fix adding the mapped controller asset as dependency
1 parent fefc61e commit ba8dcad

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/StimulusBundle/src/AssetMapper/StimulusLoaderJavaScriptCompiler.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,17 @@ public function compile(string $content, MappedAsset $asset, AssetMapperInterfac
6262
* and mark it as a "content" dependency so that this file's contents
6363
* will be recalculated when the contents of any controller changes.
6464
*/
65-
$asset->addDependency(new AssetDependency(
66-
$mappedControllerAsset->asset,
67-
$mappedControllerAsset->isLazy,
68-
true,
69-
));
65+
if (class_exists(AssetDependency::class)) {
66+
// Backwards compatibility with Symfony 6.3
67+
$asset->addDependency(new AssetDependency(
68+
$mappedControllerAsset->asset,
69+
$mappedControllerAsset->isLazy,
70+
true,
71+
));
72+
} else {
73+
$asset->addDependency($mappedControllerAsset->asset);
74+
}
75+
7076

7177
if ($mappedControllerAsset->isLazy) {
7278
$lazyControllers[] = sprintf('%s: () => import(%s)', json_encode($name), json_encode($relativeImportPath, \JSON_THROW_ON_ERROR | \JSON_UNESCAPED_SLASHES));

0 commit comments

Comments
 (0)