Skip to content

Conversation

@xDeSwa
Copy link
Contributor

@xDeSwa xDeSwa commented Sep 19, 2025

Q A
Branch? 6.4
Bug fix? no
New feature? no
Deprecations? no
Issues
License MIT

When a library in assets/controllers.json is configured with "eager (ex. live-component when eager),
it may result in duplicate modulepreload entries being generated.

This change ensures that each preload path is only added once, even if the same import
appears multiple times. It also prevents accidental duplication in importmap.php if
a library is mistakenly listed more than once.

@carsonbot carsonbot added this to the 6.4 milestone Sep 19, 2025
@carsonbot carsonbot changed the title Prevent duplicate entries in module preloads Prevent duplicate entries in module preloads Sep 19, 2025
@xDeSwa xDeSwa changed the title Prevent duplicate entries in module preloads [AssetMapper] Prevent duplicate entries in module preloads Sep 19, 2025
@smnandre
Copy link
Member

Is that something happening in basic cases ? I'm not experiencing it locally, would you have any reproducer or (a bit) more detailed explanation on "when" that would happen ?

@xDeSwa
Copy link
Contributor Author

xDeSwa commented Sep 20, 2025

when set eager

eager_controller json

Dump

dd_array_importmaprenderer

Source HTML

source_webpage

Comment on lines 76 to 78
if (!in_array($path, $modulePreloads, true)) {
$modulePreloads[] = $path;
}
Copy link
Member

@nicolas-grekas nicolas-grekas Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!in_array($path, $modulePreloads, true)) {
$modulePreloads[] = $path;
}
$modulePreloads[$path] = $path;

@nicolas-grekas
Copy link
Member

Thank you @xDeSwa.

@nicolas-grekas nicolas-grekas merged commit ef97386 into symfony:6.4 Sep 22, 2025
9 of 11 checks passed
This was referenced Sep 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants