Remove importmap entries when uninstalling a package - #1098
Open
Amoifr wants to merge 1 commit into
Open
Conversation
Member
|
What if an other UX package require the same dependency from the package you are removing... does the dependency stay in importmap.php? |
Author
|
Good catch to check! Yes, it stays: the removal list is filtered against the entries still declared by the installed packages, so anything another package still needs is skipped. This exact scenario is covered by |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #1009
When AssetMapper is used, Flex runs
importmap:requirefor the entries declared by a UX package on install, but nothing removed them on uninstall: the entries stayed inimportmap.phpforever.The tricky part is that by the time
PackageJsonSynchronizerruns (POST_UPDATE_CMD), the uninstalled package's files are gone, so itssymfony.importmapconfig cannot be read anymore. And blindly diffingimportmap.phpagainst the entries declared by the remaining packages is not an option either: it would also remove the entries the user added manually withimportmap:require.So this PR captures the entry names on
PRE_PACKAGE_UNINSTALL, while the package files still exist, and passes them to the synchronizer, which then runs a singleimportmap:removefor the captured names, except those that are:importmap.php(e.g. already removed by hand).The
synchronize()signature change is backward compatible (new optional parameter), and the webpack/package.jsonpath is untouched (obsoletefile:links were already cleaned up byremoveObsoletePackageJsonLinks()).