Thank you @datitisev, that was a great help.
Since you mentioned webpack, I took a look at the output of npm run dev, which I hadn't done before, and saw the error there as well:
ERROR in ./src/forum/index.js
Module not found: Error: Can't resolve 'fof/byobu/components/PrivateDiscussionsUserPage' in '/flarum/packages/my_extension/js/src/forum'
@ ./src/forum/index.js 5:0-89 30:11-37
@ ./forum.js
Then I edited webpack.config.js as suggested:
module.exports = require('flarum-webpack-config')({
useExtensions: ['fof-byobu']
});
and imported from '@fof-byobu' according to your instructions:
import { components } from '@fof-byobu';
Now npm run dev showed no more errors.
Then I tried to override PrivateDiscussionsUserPage:
override(components.PrivateDiscussionsUserPage.prototype, 'content', function () {
return ( [...] );
});
Strangely enough, I still had an error in the console:
TypeError: _fof_byobu__WEBPACK_IMPORTED_MODULE_4__.components.PrivateDiscussionsUserPage is undefined
I included a console.log(components) in my extension and to my surprise there was no module PrivateDiscussionsUserPage. Instead, a module PrivateDiscussionUserPage was included (without the 's' at the end of 'Discussion'), and overriding Components.PrivateDiscussionUserPage.prototype worked perfectly.
But, so I thought by myself, where the heck did this 's' got lost? The filename is PrivateDiscussionsUserPage.js, the exported default class is PrivateDiscussionsUserPage.
I finally found the explanation in the file vendor/fof/byobu/js/src/forum/components/index.js:
export const components = {
[...]
PrivateDiscussionUserPage: PrivateDiscussionsUserPage,
[...]
};
So here the module is exported as PrivateDiscussionUserPage.
I ask myself: Is this confusing naming on purpose?
And one more thing:
Doesn't the import of all modules from components affect performance? Is it not possible and advisible to import only the required modules?