Repository navigation
Description
Description
Plugin: https://wordpress.org/plugins/maxi-blocks/
GitHub: https://github.com/maxi-blocks/maxi-blocks
After updating to WP 6.6 RC 1 we're getting this in the editor:
Uncaught TypeError: Cannot read properties of undefined (reading 'mark')
at ./src/extensions/store/resolvers.js (resolvers.js:4:22)
at __webpack_require__ (bootstrap:19:1)
at ./src/extensions/store/index.js (controls.js:37:24)
at __webpack_require__ (bootstrap:19:1)
at ./src/extensions/index.js (isInSiteEditorPreviewIframe.js:8:43)
at __webpack_require__ (bootstrap:19:1)
at ./src/index.js (index.js:18:28)
at __webpack_require__ (bootstrap:19:1)
at startup:4:92
at __webpack_require__.O (chunk loaded:25:1)
react-dom.development.js:86 Warning: You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".
Switching back to WP 6.5.5 immediately fixes it, we suspect that it's somehow connected to https://make.wordpress.org/core/2024/06/06/jsx-in-wordpress-6-6/ and maybe to our babel config and / or webpack.config.js
https://github.com/maxi-blocks/maxi-blocks/blob/master/.babelrc.js
https://github.com/maxi-blocks/maxi-blocks/blob/master/webpack.config.js
Any help with fixing it is appreciated.
Step-by-step reproduction instructions
- Just update to WP 6.6 RC1
Screenshots, screen recording, code snippet
No response
Environment info
React 18.3.1
Node v20.11.1
PHP 8.2.20
If you’re using the JSX syntax in your code base, and as long as you don’t update your dev dependencies (including @wordpress/scripts, @wordpress/babel-preset-default or @wordpress/dependency-extraction-webpack-plugin), you will continue to use the old JSX transform. This will allow your plugin and built files to be compatible with WordPress 6.5, earlier versions and WordPress 6.6 as well.
No packages were updated, here are the versions:
├── @babel/plugin-proposal-class-properties@7.18.6
├── @babel/plugin-proposal-object-rest-spread@7.20.7
├── @babel/plugin-syntax-object-rest-spread@7.8.3
├── @babel/plugin-transform-spread@7.24.1
├── @babel/traverse@7.24.1
├── @floating-ui/react-dom@1.2.1
├── @langchain/openai@0.0.23
├── @loadable/component@5.15.3
├── @prettier/plugin-php@0.18.9
├── @uiw/react-textarea-code-editor@2.0.3
├── @wordpress/base-styles@4.45.0
├── @wordpress/block-editor@12.13.0
├── @wordpress/blocks@11.21.0
├── @wordpress/components@19.16.0
├── @wordpress/compose@5.20.0
├── @wordpress/data@6.14.0
├── @wordpress/e2e-test-utils@10.10.0
├── @wordpress/editor@12.13.0
├── @wordpress/element@4.20.0
├── @wordpress/env@9.4.0
├── @wordpress/hooks@3.54.0
├── @wordpress/i18n@4.54.0
├── @wordpress/icons@9.36.0
├── @wordpress/jest-preset-default@11.25.0
├── @wordpress/primitives@3.43.0
├── @wordpress/rich-text@5.20.0
├── @wordpress/scripts@27.5.0
├── babel-eslint@10.1.0
├── babel-preset-react@6.24.1
├── bezier-easing-editor@0.8.0
├── caniuse-lite@1.0.30001600
├── classnames@2.3.1
├── css-minimizer-webpack-plugin@4.0.0
├── css-to-react-native@3.0.0
├── deep-object-diff@1.1.9
├── dompurify@2.3.10
├── dotenv-webpack@8.0.1
├── enzyme@3.11.0
├── eslint-config-airbnb@19.0.4
├── eslint-config-prettier@8.5.0
├── eslint-plugin-import@2.26.0
├── eslint-plugin-jsx-a11y@6.6.1
├── eslint-plugin-prettier@4.2.1
├── eslint-plugin-react-hooks@4.6.0
├── eslint-plugin-react@7.30.1
├── eslint@8.20.0
├── html-react-parser@3.0.1
├── is-mobile@3.1.1
├── jest-canvas-mock@2.4.0
├── langchain@0.1.30
├── leaflet@1.8.0
├── masonry-layout@4.2.2
├── minify-css-string@1.0.0
├── prettier@2.7.1
├── re-resizable@6.9.9
├── react-accessible-accordion@5.0.0
├── react-color@2.19.3
├── react-compound-slider@3.4.0
├── react-drag-listview@0.2.1
├── react-icons@4.4.0
├── react-iframe@1.8.0
├── react-image-crop@10.0.4
├── react-inlinesvg@4.0.3
├── react-instantsearch-dom@6.30.2
├── react-instantsearch@6.30.2
├── react-lazy-load@3.1.14
├── react-leaflet-google-layer@2.0.7
├── react-leaflet@4.0.1
├── react-linear-gradient-picker@3.0.1
├── react-lorem-ipsum@1.4.10
├── react-paginate@8.1.3
├── react-select@5.4.0
├── react-slider@2.0.6
├── react-spinners@0.13.8
├── react-tilt@0.1.4
├── tilt.js@1.2.1
├── tinycolor2@1.4.2
├── typesense-instantsearch-adapter@2.8.0
├── typesense@1.8.2
├── uuid@9.0.1
├── w3c-css-validator@1.3.0
└── webpack-bundle-analyzer@4.10.1
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
Activity
tomusborne commentedon Jun 27, 2024
I'm experiencing this as well.
Something as simple as this causes this same error to occur:
This results in the following error:
Uncaught TypeError: Cannot read properties of undefined (reading 'mark')UPDATE - managed to fix this. We had
wp-polyfillloading on the page that was causing this error. Removed the code requiring that dep and all is well.elzadj commentedon Jun 28, 2024
Thanks for your help! I can confirm that the cause of the
Uncaught TypeError: Cannot read properties of undefined (reading 'mark')is indeed the wp-polyfill script, or something connected to it.It comes from build/index.asset.php dependency by default.
However, our custom blocks don't work.
and we still get
The error comes from the file edit-post.js, from the line
const root = (0,external_wp_element_namespaceObject.createRoot)(target);, I see it even with all the plugins deactivated:elzadj commentedon Jun 29, 2024
After some digging, managed to find this:
Uncaught TypeError: Cannot read properties of undefined (reading 'mark')and polyfill: looks like@babel/preset-envdoesn't really work with WP 6.6 RC1. I've tried the latest release and the latest alpha versions of the package, but ended up removing it from.babelrc.js- that fixed the error, and now our custom blocks work, aside of the point 2 problems:Warning: You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".- this warning shows forcreateRootthat we import from@wordpress/elementpackage, I've tried versions 6.2.0 and 5.35.0 - they both show that error forimport { createRoot } from '@wordpress/element';.I also see that error with all plugins deactivated, with 2024 theme, on a new page (note: I have scripts debug enabled):
swissspidy commentedon Jul 1, 2024
FWIW, the
You are importing createRoot from "react-dom" which is not supportedwarning is a known issue in Gutenberg itself and not caused by other plugins or anything. AFAIK it has to do with the way React is bundled in@wordpress/element. You can safely ignore this warning. (It's just a warning, not an error)As for the other issue at hand, it is indeed related to
wp-polyfill. For context, as noted in this dev note, thewp-polyfilldependency is no longer included by default in WordPress, as it is only relevant for when you are targeting older browsers.Specifically, you are using generator functions in your code base while still targeting abandoned browsers like IE 11 that do not support generators.
To address this, you need to either manually load the
wp-polyfilldependency or you simply remove this line here in your Babel config:https://github.com/maxi-blocks/maxi-blocks/blob/6a47440d6a6eb8952f416ab8983397f245515f60/.babelrc.js#L23
Your Babel config in general contains polyfills for things that have been added to browsers a long time ago. Those polyfills have long been deprecated because of that. You can basically remove all of them. I recommend just using
@wordpress/babel-preset-defaultelzadj commentedon Jul 1, 2024
Thanks for your help, now most of our custom blocks work, aside of blocks that use
typesense-instantsearch-adapter. We are getting the same.markerror for lines like this one https://github.com/typesense/typesense-instantsearch-adapter/blob/20d7d9616a7829f87d806c73653dacef8e5d3fca/lib/SearchRequestAdapter.js#L478But I guess that's a question for typesense devs, going to create an issue there.
swissspidy commentedon Jul 1, 2024
Looks like typesense/typesense-instantsearch-adapter#112 applies to you
In short: This script was built targeting older browsers such as IE11, where generators were not supported. It thus requires the regenerator runtime to be available (which
wp-polyfillprovides). You can either manually loadwp-polyfillto make it available or try to follow the steps mentioned in that issue to load the script from source and let your webpack config do the bundling. That might be as simple as this:swissspidy commentedon Jul 3, 2024
@elzadj Quick follow-up after looking into it again: I of course meant
regenerator-runtimewould need to be added manually, notwp-polyfill.mboynes commentedon Jul 10, 2024
I ran into this issue on a plugin as well even though that plugin uses
@wordpress/dependency-extraction-webpack-pluginand, through that, was includingwp-polyfillas a script dependency (and FWIW I confirmed that the wp-polyfill script was successfully being loaded in source HTML).I couldn't find a path to resolution, so I had to update the plugin's
browserslistin order to get it working again.swissspidy commentedon Jul 10, 2024
Yeah if you target Internet Explorer (which is abandoned) then you would include the regenerator code for no reason and would need to manually add
regenerator-runtimeas a dependency (instead ofwp-polyfill-- the latest version of@wordpress/dependency-extraction-webpack-pluginfixes that for you). But just updating the browserslist config makes so much more sense and your users will be thankful for the smaller bundles :)FauzanEdris commentedon Jul 18, 2024
updated the
@wordpress/dependency-extraction-webpack-pluginto version 6.3.0 solve the issue.https://www.npmjs.com/package/@wordpress/dependency-extraction-webpack-plugin/v/6.3.0
thanks!
yonnic commentedon Jul 18, 2024
The Pods Plugin is also affected by this problem and its minified code.
How can i fix it manually with this wp-polyfill issue ?
contacting Pods Author is no option as their support is dead
swissspidy commentedon Jul 18, 2024
@yonnic Their support is well and alive and they are working on this. See https://wordpress.org/support/topic/pods-not-working-with-wordpress-6-6-update/.
rilwis commentedon Sep 10, 2024
@swissspidy Is there any update about this issue?
swissspidy commentedon Sep 10, 2024
AFAIK it is supposed to be fixed in 6.7