Idea Hub notice not showing in editor
See original GitHub issueBug Description
In #3272 we added a notice to the editor for posts created for Idea Hub ideas.
This has since stopped appearing due to a change in the way the script is built. Originally, it was added as a “basic module” in our Webpack config which is a separate section of entries which have minimal optimization. https://github.com/google/site-kit-wp/blob/93d2c1b3e902cd4d91aadf82e029d0d5fabaa830/webpack.config.js#L282-L289
The regression was caused when I asked for this to be moved into our primary list of JS entries due to its internal use of SK api/cache which made it less safe to use as a basic module. In particular, api/cache relies on a GOOGLESITEKIT_VERSION
constant which is only provided to our primary modules, so cache keys were not generated properly when used as a basic module.
However, in doing so the script has stopped loading due to missing Webpack dependencies.
The asset in WP only requires our googlesitekit-i18n
, but inspecting the built script shows it requires both our runtime
(expected of all main entries), but also googlesitekit-vendor
.
},[["./assets/js/googlesitekit-idea-hub-notice.js","runtime","googlesitekit-vendor"]]]);
The vendor dependency seems a bit unnecessary but from what I can tell there are at least two reasons for this:
- Use of
global
keyword – this is a node thing which we use for consistency everywhere so Webpack loads a compatibility module from./node_modules/webpack/buildin/global.js
to handle this - Apart from that – the only thing I can see are Babel runtime async-to-generator modules so that would imply any async function would require vendor as well
The fix is as simple as adding the missing dependencies to the Asset
instance.
Steps to reproduce
- Create a draft from an Idea Hub idea
- Edit the post
- Note the notice at the top that identifies the source idea is not shown
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The Idea Hub notice for display in the post editor should be shown when viewing a post created for an Idea Hub idea (unless dismissed)
Implementation Brief
- Explicitly add the vendor and runtime assets to the
googlesitekit-idea-hub-notice
asset’s dependencies - Merge https://github.com/google/site-kit-wp/pull/3828
Test Coverage
- No changes
Visual Regression Changes
- No changes
QA Brief
- Follow above steps to reproduce, you should see the notice now
Changelog entry
- N/A
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Here is the issue which would fix this in a more holistic way which would be nice to revisit https://github.com/google/site-kit-wp/issues/3195 (cc: @felixarntz)
Thanks for clarifying that @felixarntz
QA Update: ✅
Verified:
This post was created from an idea you picked in Site Kit’s Idea Hub: <Topic idea title>