felixarntz / ai-services

Makes AI centrally available in WordPress, whether via PHP, REST API, JavaScript, or WP-CLI - for any provider.
https://wordpress.org/plugins/ai-services/
GNU General Public License v2.0
24 stars 2 forks source link

Console error appears for core/interface already being registered #13

Open westonruter opened 3 hours ago

westonruter commented 3 hours ago

When the plugin is active, every page includes the following error in the console:

image

felixarntz commented 2 hours ago

@westonruter Thanks for raising it in an issue!

I'm aware of this error, though I think this cannot be fixed at this point. That said, while it's reported as a JS error, it doesn't lead to any actual problem.

The reason this is happening is because the @wordpress/interface package is experimental and therefore not built into a WordPress Core asset wp-interface (like more or less all other WordPress packages are). It is used by @wordpress/components / wp-components for instance, and because it's also used in the plugin's @ai-services/components script, both of these plugins include that codebase and thus try to register the same store.

Again, not a real problem, so it's a low priority bug, but I agree it would be nice to fix. Most likely, this will happen more or less automatically once the @wordpress/interface graduates into non-experimental status.

For now, what might be worth considering is to not use it in @ai-services/components (which is a generic components package), but maybe move the relevant components into a separate @ai-services/interface asset, since those interface components are only loaded on the plugin's settings screen. In other words, this wouldn't fix the issue at all, but it would mean the JS error would only occur in the plugin's settings screen rather than everywhere the chatbot is available.