Updated: Comment #15
At the moment the only reason field CMI import works is because field.field.* is before fieid.instance.* this sort of dependency management is not good enough.
Seefor where this becomes an issue.
Proposed resolution A
Based on discussion with alexpott and heyrocker in IRC, to manage config import issues inwe need to have ability for other modules to affect the priority / order of what is getting imported in a config import.
Basic idea is to abstract out the array list of changes being imported in the ConfigImporter class to a separate object (a ConfigList). This object can then be passed to other modules by firing a 'prioritise' event via the event dispatcher, just before we do the actual config import.
Subsequently we would implement a PrioritisableArray object utility (similar to NestedArray / MapArray) in Drupal\Component\Utility, that we can use to affect the priority of the items being imported.
Proposed resolution B
We implement import cycles and defer importing until all the dependencies are met. We would need to be able to validate config and we will need to bail out if we end up in a loop.