Many APIs come with plugins that improve the power of the API and make using it more magical. However, some APIs can use a lot of plugins (like Publish) and the amount of import
s you have to place on the top of your file gets huge.
@attached import
would import the module it is in every time the module being imported is imported.
With that, a simple import Publish
would give also import import SplashPublishPlugin
too as long as SplashPublishPlugin
has @attached import Publish
somewhere in the module.
If that doesn't make since, think of it this way: @attached
is the reverse of @_exported
.
Sometimes, however, you might want to get only the primary module and none of the plugins. This would be done by placing @plain import
instead of just import
.
With that, if you use @plain import Publish
it would only import Publish
and not SplashPublishPlugin
even if SplashPublishPlugin
has @attached import Publish
somewhere in the module.