The many packages in Alfa interact with each other and export/import a lot of code from one package to the other. This often lead to long list of imports when many bits from one package are needed, plus a risk of name collision when things are imported from different packages.
Both these problems can be alleviated by renaming import; using the import * as foo
syntax; or bundling everything into a namespace that is exported.
We will use namespaces to bundle export from each package and never export individual functions. As much as possible, we will keep that separation also at the file level. Functions that are exported from a file will be marked as internal and only the re-export from a namespace in the package will make its way to the API.
For functions closely related to a data structure which is modelled by an existing class, the class and namespace will share the same name in order to merge into a single ES object.
Accepted.
Since we cannot import individual functions anymore, bundle size tend to increase. This is not a major problem for our use cases because the time to download Alfa is normally not critical.
Imports from other packages are usually limited to a few namespaces. Dotted notation makes it fairly clear in the code where some function comes from.