There is very little documentation online on the proper use of C++20 modules in shared libraries. Many folks [are](https://titanwolf.org/Network/Articles/Article?AID=bfaead97-7ac2-4416-89b5-3dda5951a9b1#gsc.tab=0) [clearly](https://stackoverflow.com/questions/38060483/will-c1z-modules-replace-the-need-for-dllimport-dllexport-on-windows) [interested](https://stackoverflow.com/questions/52286991/what-is-the-expected-relation-of-c-modules-and-dynamic-linkage), but I haven't been able to find a clear solution.

In MSVC, you need to use `dllexport` when compiling the library, and `dllimport` when consuming the symbols. This can be done using macros in "legacy C++", but this does not work with C++20 modules, since the code is only compiled once, regardless of preprocessor directives.

[This post](https://stackoverflow.com/questions/38060483/will-c1z-modules-replace-the-need-for-dllimport-dllexport-on-windows) suggests that you only need to use `dllexport` now, and that `dllimport` will be taken care of automatically by the compiler. However, this comes from a comment which has now been deleted, and I couldn't find any reliable source on the topic.

How is one expected to create a shared library using C++20 modules?