WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
9.99k stars 4.01k forks source link

WP 6.6 RC1: Custom blocks stopped working #63009

Closed leoloso closed 2 days ago

leoloso commented 4 days ago

Description

In my plugin, I have a CPT that loads custom blocks. After upgrading to v6.6 RC1, all the custom blocks stopped working:

Screenshot 2024-07-01 at 16-20-13 Add New GraphQL Schema Configuration ‹ Gato GraphQL — WordPress

The compiled blocks are targeting WordPress 5.4, they work all the way down there. If possible, I'd expect them to still work on WP 6.6.

Error in the JS console:

Uncaught TypeError: L.a is undefined
    <anonymous> https://gatographql-pro.lndo.site/wp-content/plugins/gatographql/blocks/schema-config-composable-directives/build/index.js?ver=7bc47881f5458ab13f7b8b29b9ee3745:1
    a https://gatographql-pro.lndo.site/wp-content/plugins/gatographql/blocks/schema-config-composable-directives/build/index.js?ver=7bc47881f5458ab13f7b8b29b9ee3745:1
    n https://gatographql-pro.lndo.site/wp-content/plugins/gatographql/blocks/schema-config-composable-directives/build/index.js?ver=7bc47881f5458ab13f7b8b29b9ee3745:1
    <anonymous> https://gatographql-pro.lndo.site/wp-content/plugins/gatographql/blocks/schema-config-composable-directives/build/index.js?ver=7bc47881f5458ab13f7b8b29b9ee3745:1
    <anonymous> https://gatographql-pro.lndo.site/wp-content/plugins/gatographql/blocks/schema-config-composable-directives/build/index.js?ver=7bc47881f5458ab13f7b8b29b9ee3745:1

I did npm start to get a friendlier error msg:

Uncaught TypeError: _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a is undefined
    js resolvers.js:60
    Webpack 14
        __webpack_require__
        js
        __webpack_require__
        js
        __webpack_require__
        js
        __webpack_require__
        js
        __webpack_require__
        js
        __webpack_require__
        checkDeferredModules
        <anonymous>
        <anonymous>
[resolvers.js:60:3](webpack:////Users/leo/GitRepos/GitHub/Projects/leoloso/PRO/submodules/ExtensionStarter/submodules/GatoGraphQL/layers/GatoGraphQLForWP/plugins/gatographql/packages/components/src/store/resolvers.js)
    js resolvers.js:60
    Webpack 14

That first error on resolvers.js:60 points to this line in the code:

    * getTypeFields( keepScalarTypes = false, keepIntrospectionTypes = false ) {

The block uses these deps in package.json:

{
    "devDependencies": {
        "@gatographql/api-fetch": "file:../api-fetch",
        "@wordpress/base-styles": "^2.0.0",
        "@wordpress/components": "^10.0.0",
        "@wordpress/compose": "^3.19.0",
        "@wordpress/data": "^4.22.0",
        "@wordpress/edit-post": "^3.21.0",
        "@wordpress/scripts": "^12.1.0",
        "prettier": "npm:wp-prettier@2.0.5",
        "raw-loader": "^4.0.2",
        "react-select": "^3.0.8"
    }
}

Switching to @wordpress/scripts version 27.9 also produces the same error.

Step-by-step reproduction instructions

  1. Install WP 6.6 RC1
  2. Have plugin Gato GraphQL installed
  3. Go to "Schema Configurations" > Add new (eg: mysite.com/wp-admin/post-new.php?post_type=graphql-schemaconfig), which goes to the WordPress editor for that CPT
  4. All the blocks fail loading

Screenshots, screen recording, code snippet

Screenshot 2024-07-01 at 4 49 07 PM

Environment info

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

leoloso commented 2 days ago

Still happening with RC2

talldan commented 2 days ago

@leoloso It's not related to anything in the gutenberg codebase, as with the gutenberg plugin active on 6.5, your plugin works too.

I did a git bisect on WordPress core code and narrowed it down to this core commit - https://github.com/WordPress/wordpress-develop/commit/f525e665b6ea6e88289d82cad5fc1dfac57db109.

It seems like the removal of some polyfills (that your plugin must depend on) has caused the issue, probably with the generators given where the error happens. You could probably look to include the polyfills in your own compiled code to solve the issue, though I'm not personally aware of what's required.

If you want to discuss it, here's the trac ticket (not sure if you're aware, but trac is the bug ticketing system for WordPress core, you'll need a wordpress.org user account to comment) - https://core.trac.wordpress.org/ticket/60962.

I'll also drop a comment on the trac ticket to mention this issue.

talldan commented 2 days ago

@leoloso Reading through that trac ticket, the comment here might be relevant for you.

swissspidy commented 2 days ago

Let's continue discussion at https://github.com/GatoGraphQL/GatoGraphQL/issues/2710 otherwise

leoloso commented 1 day ago

Hi @talldan @swissspidy I appreciate your input and help. Thanks!

I've redone all the data stores in my plugin: I've removed the generators (so no need for the polyfill), using the source code from here:

https://github.com/WordPress/gutenberg/blob/1b6b4b8d8439b7cc0b0d90334a3b7cccaa665b45/packages/block-directory/src/store/index.js

The JS error doesn't happen anymore, hurray!

However, there is another problem. I'll post it on a separate issue.