I am using an email program (MailMate) on macos that stores emails in a format that seems close, but not identical to that used by Apple Mail. The format uses folders to mirror IMAP folders, and stores messages as .eml files. E.g, a message that on the IMAP server is in folder B, which is a subfolder of A, will be A.mailbox/B.mailbox/message.eml on disk.
(This certainly is not super high priority, as this is mostly me trying to avoid just running Apple Mail and downloading everything -- 25 GB's worth of emails -- again.)