So I have been toying with extensions extending other extensions and kind of hit a wall.
The webpack config has a useExtensions option that seems designed for that.
It seems to create a map from imports like import something from '@vendor-extension'
to the global object flarum.extensions['vendor-extension']
.
First I think there's an error in the README of the webpack config as extensions do not use the vendor/extension
syntax in the flarum.extensions
object, but vendor-extension
. In this case there is no flarum/tags
entry, but a flarum-tags
entry.
My initial expectation was to be able to import stuff like @flagrow-user-directory/components/UserDirectoryPage
, but it doesn't seem to be working that way, as we can only import from the root of the package (only @flagrow-user-directory
and not @flagrow-user-directory/something
).
The flarum.extensions
entries actually only contains the objects exported by the index.js
file of the extension. As of beta 8, it seems no extension exports anything. I see the code is ready to accept an extension extenders
array, but I have not seen any extension making use of that feature.
This also makes the flarum-tags
example crappy because the extension is not actually exporting anything, so we wouldn't be able to use it that way anyway 💩
In Flagrow Upload I have now exported the page from the index.js
file, so it is now accessible at flarum.extensions['flagrow-user-directory'].UserDirectoryPage
. But having import UserDirectoryPage from
@flagrow-user-directoryor
import {UserDirectoryPage}in a second extension didn't seem to work and
UserDirectoryPageended up being
undefined`.
So how are we supposed to import such things ? For now I have manually accessed the page component via the flarum.extensions
global object, so I'm not using useExtensions
at all.
I have not managed to find any existing extension making use of the feature. fof/secure-https has defined useExtensions
in its config, but I don't believe it serves the intended purpose, as they actually install the fof/components
package and import directly from there, not using flarum.extensions
at all.
Maybe @Toby you could share some insights on how you expected it to be used ?