Repository navigation
My Jetpack: Fix the onboarding wizard crashing on WordPress 7.0 - #53880
DevinWalker wants to merge 1 commit into
Conversation
…on WordPress 7.0 The wizard imports ThemeProvider from @wordpress/theme, which was externalized to core's wp-theme script. WordPress 7.0's wp-theme exports only privateApis, so ThemeProvider was undefined and the wizard threw on render. bundleWpUiDeps bundles @wordpress/theme and @wordpress/private-apis, as Boost, Protect and the Jetpack plugin already do. None of My Jetpack's webpack entries unlock private APIs from an external wp-* script.
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryThis PR did not change code coverage! That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷 |
|
Folding this into #52775 so the wizard and its WordPress 7.0 fix land together. Closing this one. |
Fixes #
Proposed changes
@wordpress/theme(and@wordpress/private-apis) viabundleWpUiDeps: true. Boost, Protect and the Jetpack plugin already use this option for entries that bundle@wordpress/ui.ThemeProviderfrom@wordpress/theme. With the default config, that import is externalized to core'swp-themescript. On WordPress 7.0,wp-includes/js/dist/theme.jsexports onlyprivateApis, withThemeProviderlocked inside it. 7.1 added the public export. So on 7.0,ThemeProviderisundefined, and the wizard throws "Element type is invalid … got: undefined" on its first render (React error fix certain issues with widget visibility conditions and static pages #130 in production). The page stays blank. WordPress 7.0 is the minimum version Jetpack, Protect and Boost support.wp-*script. None of My Jetpack's three webpack entries do:unlock()orprivateApisuse.onboarding,header-controlsandasync-notification-bubblecontains noprivateApisreference at all.@wordpress/ui's ownprivateApisfallback is tree-shaken out of these entries.wp-build, which this option doesn't touch.onboarding.asset.phpno longer depends onwp-theme. It now depends onwp-compose, which the bundled theme uses.header-controlsandasync-notification-bubblekeep the same dependencies. Only their module IDs change.onboarding.jsgoes from 262,199 B to 338,865 B (62,143 B to 88,901 B gzipped). The extra code is@wordpress/themeandcolorjs.io, whichThemeProvideruses to build its color ramps at runtime. Core'swp-themecarries the same code, but 7.0 offers it only as a private API. Once My Jetpack: load the onboarding wizard in its own chunk #53750 lazy-loads the wizard, this cost moves into the wizard's chunk, so it's only downloaded when the flag is on.my-jetpack-onboarding-wizardfeature flag, so nothing changes for site owners yet. The changelog entry is only onpackages/my-jetpack.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
You need a site running WordPress 7.0. 7.1 exports
ThemeProviderpublicly, so the bug doesn't show there. Gutenberg replaceswp-themetoo, so leave it inactive.wp core download --version=7.0 --forceto get 7.0.localhostand127.0.0.1as offline mode, and My Jetpack doesn't load in offline mode. Use a JN site, or addadd_filter( 'jetpack_is_local_site', '__return_false' );to an mu-plugin.add_filter( 'jetpack_feature_flag_enabled_my-jetpack-onboarding-wizard', '__return_true' );page=my-jetpack&step=onboarding, and the page is blank. The console shows "Element type is invalid … got: undefined", andObject.keys( wp.theme )is[ 'privateApis' ].projects/packages/my-jetpack/build/onboarding.asset.php:wp-themeis no longer in the dependency list.