Open ecgan opened 1 month ago
Looking at the source code for
jetpackConfigHas
andjetpackConfigGet
, it seems that it would only work for projects / packages within the Jetpack monorepo, and wouldn't work for plugins outside of the monorepo.
It's not a inside/outside monorepo issue, it's that since #38877 it can't be set anywhere. More specifically, the jetpackConfig
stuff is scoped to the Webpack bundle, and since #38877 everything should be using the one bundle from the Connection PHP package rather than including the Connection-JS code inside their own bundles.
At the time everyone we asked (e.g. p1724180304428379/1723632909.832209-slack-C05PV073SG3) said that the consumer_slug
isn't actually recorded or used for anything. If that remains true, maybe we should remove it entirely? Or if we want to keep it, then yeah, it would need to be passed in to the appropriate components/hooks.
I would like to use
ConnectButton
component anduseConnection
hook from https://www.npmjs.com/package/@automattic/jetpack-connection in my own custom WooCommerce plugin.However, when I use it, during the
registerSite
process, I noticed that theplugin_slug
/consumer_plug
is set to'connection_package'
, and there isn't a way for me to override it:https://github.com/Automattic/jetpack/blob/13222c64b1c391f2a4f9d119773a70c47bb7b2f2/projects/js-packages/api/index.jsx#L92-L94
https://github.com/Automattic/jetpack/blob/13222c64b1c391f2a4f9d119773a70c47bb7b2f2/projects/packages/connection/webpack.config.js#L59
I looked into https://www.npmjs.com/package/@automattic/jetpack-config, and I've put the following webpack config in my plugin, but it doesn't work:
Looking at the source code for
jetpackConfigHas
andjetpackConfigGet
, it seems that it would only work for projects / packages within the Jetpack monorepo, and wouldn't work for plugins outside of the monorepo.So, my suggestion in this issue is to expose
plugin_slug
in theConnectButton
component anduseConnection
hook, so that third party plugins can specify their ownplugin_slug
.