fix: Defer remote editor references to @wordpress modules#198
Merged
fix: Defer remote editor references to @wordpress modules#198
@wordpress modules#198Conversation
kean
approved these changes
Oct 21, 2025
Contributor
kean
left a comment
There was a problem hiding this comment.
The error leaves the remote editor in a broken state.
My bad – I never used a remote editor for testing.
| // Lazy-load getBlockTypes to defer the import until this function is called. | ||
| // In the remote editor, dependencies are loaded asynchronously, so this ensures | ||
| // window.wp.blocks is defined before we access it. | ||
| const { getBlockTypes } = await import( '@wordpress/blocks' ); |
Base automatically changed from
task/ios-demo-app-discovers-remote-editors
to
trunk
October 21, 2025 20:00
We cannot reference `@wordpress` modules in the remote editor runtime until after the site-specific scripts are loaded. Utilizing a dynamic import defers the global `window.wp` reference. We now also apply the same transformations made to static imports to dynamic imports as well.
b57569c to
b57d479
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Fix undefined reference error causing remote editor loading failure.
Why?
Address #193 (comment). The error leaves the remote editor in a broken state.
How?
Update
getBlockTypes()to lazy-load the required@wordpress/blocksdependency, ensuring the relevant global is available before access it.Testing Instructions
Accessibility Testing Instructions
N/A, no user-facing changes.
Screenshots or screencast
N/A, no user-facing changes.