Description
Symfony version(s) affected
7.1.9
Description
I have a JS dependency (ag-grid-community version 33) which contains an exceptions message in the source code telling a developer how to import itself as module. This message is picked up by AssetMapper as an import (as mentioned in the docs it can't distinguish comments or strings from actual code). This leads to asset-mapper creating an asset for ag-grid-community with a dependency to ag-grid-community and in the end to an endless loop in Symfony\Component\AssetMapper\ImportMap\ImportMapGenerator::addImplicitEntries
.
How to reproduce
Add ag-grid-community to importmap.php
in version 33 and load the the page.
'ag-grid-community' => [
'version' => '33.0.2',
],
Possible Solution
I am aware that it is not possible to implement a solution distinguishing comments/string from actual syntax when checking js files for dependencies. It might make sense to add a mechanism to detect and prevent endless loops if in the dependency tree a library creates a loop by referencing itself. If circular dependencies should not be broken by asset-mapper it might make sense to allow some sort of ignore, because we have no impact on the third party library and in my opinion the error message with code snippet in their ag-grid library makes totally sense and is very helpful to their users.
Additional Context
Here is a screenshot where you can see the error message in the ag-grid source producing the import:
