How to export custom user fields configuration?
Modules can add in the config/optional directory any configuration file for fields or  entities. For example, the Forum module uses the config/optional directory to define a new content type and its fields, but it could have as well defined fields for a content type defined from another module. Keep in mind that in this case, the module need to define an explicit dependency from the other in the configuration file for the field. 

For an example of using the config/install directory for defining new bundles and its fields, see the config/install directory used from the Standard profile.