fix: expose @wordpress/theme as window.wp.theme - #614
Conversation
The package was only reachable transitively through @wordpress/dataviews, but the editor now imports it to expose window.wp.theme. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VnQd7G77gehA2PgnzKvFei
Jetpack's editor bundle now includes @wordpress/ui 0.21, whose ThemeProvider shim reads window.wp.theme at module-evaluation time and throws when it is missing, so no Jetpack block registers. WordPress registers the wp-theme script in wp-admin, but GutenbergKit populates window.wp itself and had no theme entry. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VnQd7G77gehA2PgnzKvFei
XCFramework BuildThis PR's XCFramework is available for testing. Add the following to your .package(url: "https://github.com/wordpress-mobile/GutenbergKit", branch: "pr-build/614")Built from fe48f8d |
|
@dcalhoun This looks good and I'll approve it, but Claude had this to say:
I'm not sure if that's an actual problem but thought I should mention it. |
|
@nbradbury thanks for sharing. The finding is correct, but it is not new to these changes. The added |
What?
Expose
@wordpress/themeaswindow.wp.themealongside the other WordPress globals, and add it as a direct dependency.Why?
Jetpack blocks fail to register in the editor against Jetpack's upcoming 16.2 release, which currently ships on the wordpress.org trunk build that
.wp-env.jsoninstalls. The web E2Ethird-party-blocksspec fails as a result.Jetpack's editor bundle now includes
@wordpress/ui0.21, whoseThemeProvidershim readswindow.wp.themeat module-evaluation time and throws when it is missing:In wp-admin, WordPress registers the
wp-themescript. GutenbergKit populateswindow.wpitself and did not definetheme, and the Jetpack editor-assets endpoint treatswp-handles as core-provided, so nothing else fills the gap.How?
Import
@wordpress/themeinwordpress-globals.jsand assign it towindow.wp.theme. The installed 0.8.0 exposesprivateApis, which the@wordpress/uishim unlocks as a fallback forThemeProvider. The package was previously only a transitive dependency via@wordpress/dataviews, so it is now declared directly.Testing Instructions
make wp-env-start.npx playwright test e2e/third-party-blocks.spec.js.trunkthey fail with the error above.Accessibility Testing Instructions
N/A. No UI changes.
Screenshots or screencast
N/A
🤖 Generated with Claude Code
https://claude.ai/code/session_01VnQd7G77gehA2PgnzKvFei