SPM: automatic detection of module source directories

i’ve written before about how painful it is to use SPM with moderate-to-large packages, and i’ve come to the conclusion that a major component of this issue is the way that SPM forces a flat directory layout on our projects.

while it’s possible to simulate a more hierarchical directory layout using custom source directory paths, this approach is brittle and involves an extrinsic mapping that needs to be updated when modules are renamed, merged, or otherwise restructured. which are things i do quite frequently.

custom directory paths are also overly general - the feature is designed to support arbitrary module ←→ source directory mappings, but really all i need to achieve a better project organization is to be able to relocate the source directories without necessarily giving them a name that is different from the target name.

it seems to me that SPM ought to be able to simply infer where module source directories are located, perhaps using one of:

  • a custom directory extension (e.g. MyTarget.module)
  • some kind of anchor file in the source directory

basically, instead of:

- Database/
- Frontend/
- Queries/
- Records/

which is ordered alphabetically and difficult to navigate, i would like to be able to have:

- Database/
    - Database.module/
    - Queries.module/
    - Records.module/
- Frontend/
    - Frontend.module/
    - HTML.module/