-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a mechanism to exclude packages from processing #76
Add a mechanism to exclude packages from processing #76
Conversation
This is an array of package slugs. Any package included here won't be processed by Mozart: it won't have its namepsaced changed and won't be moved from its original location. Namespace references to these packages won't be changed. This is useful if there are dependent packages whose namespace shouldn't be changed, for examle "psr/container".
afd5465
to
421fd60
Compare
Hi @Konamiman, thank you for this contribution to Mozart! I'd like to understand use cases for new features, such as this one, before merging them in. Not because I'm opposed to having new features, but Mozart is made with a specific goal in mind and I don't want it to deviate it from that goal too far. Can you elaborate on why you'd want to ignore a specific package from being replaced and moved? |
Hello! Sure thing. I work at Automattic and my motivation for this feature is being able to use PHP League's container in WooCommerce. We introduced it a few months ago but we had to revert it since it conflicted with a plugin using a different version of the same package. In order to reintroduce it we needed to change its namespace at build time, for now we're using a hacky script for that but Mozart provides a cleaner way. League's Container, however, depends on the psr/container package, since it implements PSR-11's There is another reason for leaving this package unchanged, though. League's Container has a feature named delegate containers, by which a secondary container can be registered in case the main one can't resolve a given class. We want to allow WooCommerce plugins to register their own PSR-11 containers (be those League's or others with similar functionality), and be able to use ours as a delegate container. But this will only be possible if our container implements And that's my story. For now I'm using my own fork with the functionality of this pull request merged in, but of course I would prefer to use the official Mozart package. 🙂 |
I'm a bit late to the game, but just a note to say that was already possible using
|
@BrianHenryIE I agree, this is functionally the same, but... They are two separate things, that can lead to the same end result. While this new |
Agree |
Am I missing something or is this solution not recursive? It seems that tertiary dependencies still get moved even when excluded. Edit to provide some context:
I then tried adding |
@Spreeuw Good find. Can you confirm that this still is happening on the current |
Thanks. I understand this may not be the best place for discussion, I just wanted to mention the thing about not being recursive here and then ended up with that much larger context edit :) With current master (5d8041f), the That fatal error above does not occur as a result of #82, so that's a good thing (and removes the requirement for me to exclude them). Guzzle still doesn't work though, throwing: TBH I'm not sure what exactly the issue is here, and I didn't want to post an issue just saying "Guzzle is not working". I may open an issue if I have more information to give you. |
If I understood correctly, this will simply not process files in the excluded packages' folder. I haven't read the example with WooCommerce yet, but I am finding it hard to imagine cases where this would be desirable. Exclusion is useful based on FQNs, and if an FQN gets prefixed, then it should get prefixed in all packages. If it is excluded, then it should not get prefixed in any packages. IMHO. |
Here we add an optional
excluded_packages
configuration key, which is an array of package slugs. Any package included here won't be processed by Mozart: it won't have its namepsaced changed and won't be moved from its original location. Namespace references to these packages won't be changed either.This is useful if there are dependent packages whose namespace shouldn't be changed, for examle
psr/container
. Examplecomposer.json
:Note that this pull request is similar in intent to the one to skip namespaces by leoloso, but in this case we are excluding whole packages, not namespaces.