-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gutenberg: update packages to latest versions #27778
Merged
+266
−224
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dd76eab
Gutenberg: update packages to latest versions
vindl ed8c75e
Add postLock mock to get the editor to boot
vindl d34ba9c
Fix test errors in block-serialization-spec-parser
vindl ac207a6
Try removing the jQuery external
vindl fdbc969
Register data plugins
vindl bf78286
Ensure that @wordpress/core-data store is created only after plugin r…
jsnajdr 06bcef3
Remove superfluous userId check
vindl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`block-serialization-spec-parser parse() works properly 1`] = ` | ||
Array [ | ||
Object { | ||
"attrs": Object {}, | ||
"blockName": "core/more", | ||
"innerBlocks": Array [], | ||
"innerHTML": "<!--more-->", | ||
}, | ||
] | ||
`; |
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The trouble is that this plugin registration call comes too late, at a time when the
@wordpress/core-data
store is already created and registered. Without the appropriate middlewares.The
@wordpress/core-data
store is created during the static initialization of the module, i.e., when the import statementis evaluated.
That happens earlier in this file when importing the
gutenberg/editor/main
module. That module imports@wordpress/core-data
and even if it didn't, importing anything from@wordpress/editor
will recursively import (an initialize)core-data
.The only way to escape the static initialization is to import the
gutenberg/editor/main
using arequire()
call after callingregisterDataPlugins
. That's what I did in bf78286 and it seems to have fixed things.It would be better (for Calypso at least) if
@wordpress/core-data
exported an initialization function that we can call at our convenience instead of initializing statically. We can only register the plugins once we know theuserId
(for the persistence plugin) and that's not available yet when modules are statically evaluated. We need to wait at least for the Redux store initialization.How exactly did you try to do that? Apparently I was more lucky when trying the same thing 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried moving the registration call around to get it to execute before
import '@wordpress/core-data';
and added some logging, but completely missed the fact that the above will always be executed first during static initialization. :(There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix and detailed explanation Jarda! 🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one more thing:
registerDataPlugins
will be called every time we enter a Gutenberg route. Open editor, navigate elsewhere, open editor again -- two calls.The same thing happens with the
registerCoreBlocks
anddisableTips
calls when mounting theGutenbergEditor
React component.All these calls should only ever happen once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is partly a pre-existing problem we've decided to start a follow up issue and handle it in a separate PR: #27882