Seems like plugins almost always have some sort of setup to go through when they’re first used. Really, they’d want to just run that code when first imported. But presumably there is no way creators can do that, currently. As it’s such a common use-case, having something like this built-in for plugins would be useful, I think.
Ah, no, good catch - that would have re-run every time. I’ve updated the code above to fix that.
Yep,
$output
will resolve towindow.__fooPluginFn
which is thefoo
function, so if you’ve gotfooPlugin={import:foo-plugin}
then you can writefooPlugin.prop
immediately and it’ll work fine.Cool 👍
Basically, an
$onload
function to be called like that automatically would be all it takes, I think. I don’t think I’ve seen the actual importing code, but presumably it injects stuff into the top-level page or something. At which point it could call the onload maybe?