-
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
Conversation
That's a great PR description, thank you so much for your effort! Generated by 🚫 dangerJS |
Currently running into Update: resolved in 6824a9ade17c24775170fc57ac4d78c1d7dff3fd, the editor shell boots correctly now. |
The editor boots up with the above fix, but I'm seeing some new errors in the console: |
c970b90
to
a65b888
Compare
I think that error is from redux-thunk, I tagged Team Calypso in case they had any hints on how to better debug that. |
This is an error thrown by Redux itself, when it's told to dispatch an action that's not a plain object ( I see that the middlewares to handle These generator actions come from My local Calypso uses |
a65b888
to
0becfea
Compare
Thanks Jarda!
FWIW so far I tried registering them when editor mounts but the issue remains. import { plugins, use } from '@wordpress/data';
...
use( plugins.asyncGenerator );
use( plugins.controls ); |
The async generator is deprecated. We'll consolidate all of our actions and resolvers to use the controls plugin.
What issue? |
0becfea
to
9f245e3
Compare
@youknowriad the one described in #27778 (comment):
|
Adding the plugins should fix it in theory 🤷♂️ Maybe we're adding them too late? |
That was my suspicion too, tried moving them before |
webpack.config.js
Outdated
|
||
// jquery is only needed in the build for the desktop app | ||
// see electron bug: https://github.com/atom/electron/issues/254 | ||
if ( calypsoEnv !== 'desktop' && ! config.isEnabled( 'gutenberg' ) ) { |
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.
We shouldn't use config feature flags this way at build time. Feature flags are meant for runtime decisions, not build time ones.
The problem will become apparent if / when gutenberg is enabled on wpcalypso or staging, but disabled in production. We share a build across those environments, so wpcalypso and staging will likely still have the external set.
6fc60d8
to
fdbc969
Compare
|
||
if ( ! siteId ) { | ||
return; | ||
} | ||
|
||
unsubscribe(); | ||
|
||
if ( ! userId ) { |
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.
This check should be never needed. Calypso boot guarantees that if a user is logged in, current user ID is set to the right value from the very moment when the Redux store is created. No need to ever wait for it.
If no one is logged in, the Gutenberg section won't be loaded at all, because it doesn't have the enableLoggedOut
flag.
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.
Removed in 06bcef3.
return; | ||
} | ||
|
||
registerDataPlugins( userId ); |
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 statement
import '@wordpress/core-data';
is 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 a require()
call after calling registerDataPlugins
. 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 the userId
(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.
Adding the plugins should fix it in theory 🤷♂️ Maybe we're adding them too late?
That was my suspicion too, tried moving them before core-data store initialization but no luck so far.
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.
How exactly did you try to do that? Apparently I was more lucky when trying the same thing 🙂
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
and disableTips
calls when mounting the GutenbergEditor
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
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'm not knowledgeable enough for the code part, but after smoke testing Gutenberg and Calypso, I haven't found anything that breaks up all the things.
So, test-wise, this LGTM!
Resolves #27649
Changes proposed in this Pull Request
Updates the Gutenberg npm packages to their latest versions released on 11th of October.
Testing instructions
Testing jQuery removal from externals
I discussed this with @blowery and it should be safe to remove the jQuery from externals.
import jQuery
in the Calypso codebase.