You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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:
The text was updated successfully, but these errors were encountered:
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 is possible... or at least it's possible in most of the cases.
I even opened a PR (twice) introducing a sequence parser for that (which would have correctly detected the import as "non code" in your specific scenario and ignored the import)
But i sincerely understand this is not the sexiest PR to review, also not everyone knows AssetMapper internals, or even uses it.
And if the code itself works, i'm not sure of the "integration" right now (a dedicated class, a function, with or without the VO..)
If circular dependencies should not be broken by asset-mapper it might make sense to allow some sort of ignore
There is a mecanism preventing circular dependencies... but none that checks if a file imports itself.
But this is easy to add and could avoid this kind of scenario :) I'll open a PR later tonight.
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.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:
The text was updated successfully, but these errors were encountered: