In one of my plugins I would like to use the color-input component. However this component is located in the discourse/admin folder so whenever I try to import it as a non-admin user, it cannot be found because Discourse prevents non-admin users from loading admin components (if I understood correctly).
Would it make sense to move this component outside of the admin folder?
The alternative is obviously to use my own component or copy the existing one, but I wanted to ask you first. Maybe there is a way to load this component regardless of the user status but I don’t know how.
Or perhaps, make all admin stuff available in TCs/plugins (only programmatically via customizations) that can be used by normal users? That may be useful as well.
I don’t know if the plugin’s bundles are tree-shaked so making all admin stuff available could have a big cost. But more generally I agree it would be great to be able to use those components which are very nice.
Yeah this is exactly the problem - we don’t (yet) have any automatic tree-shaking. Admin modules are separated out manually so that regular users don’t have to pay the cost of loading them over the network.
That’s probably the best bet. IIRC the color selector is fairly self-contained so it should be easy to copy. That also has the advantage of insulating your plugin from any changes made to the core component (which isn’t really considered “public api”)