-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
New block created with @wordpress/scripts@28 don't show up on wordpress #62202
Comments
+1 However if you put the block inside a template html file with it's block name it appears on the front end. |
Thanks for the report. I was able to reproduce this issue. I built the block with scripts version 27 and 28 and found a difference in the contents of version 27.9: <?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-i18n'), 'version' => 'd97fdb9bbdb79e4913a4'); version 28.0: <?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-i18n'), 'version' => 'b0e4f78143cfbd1f56d2'); If I manually change this to |
With v28 scripts all my blocks in my custom block theme stop working, was there any drastic change that I had to take into account when moving from 27 to 28? |
Same here, after updating to v28 custom blocks completely disappeared.
reverting to --- edit --- I just noticed that removing those lines: gutenberg/packages/dependency-extraction-webpack-plugin/lib/util.js Lines 46 to 48 in ceb8949
solves the issue. Maybe this is something related to the-new-jsx-transform? |
same problem here. If i replace pacakage-lock.json with 27.9.0 the block works but with 28.0.0 it disappears. |
Same problem here. I downgraded to 27.9.0 to make my blocks work again. |
cc @youknowriad @Mamaduka who worked on / reviewed the original PR. The way it's currently built is not compatible with WP < 6.6 |
The problem is going to exist for quite some time because many plugins target older major versions of WordPress. In WP 6.5 and older there is no |
Thanks for creating the issue and sharing your concern. It's clear that we overlooked a bit the impact of this change. Especially for the create-block package. That said, the solution her is to actually stick to the old version of wp-scripts in the build tooling. Dev Tools and Production dependencies don't need to be updated at the same time. Plugin authors that already have a build tool in place don't need to touch their dependencies. I think there's a couple of things we should do here: 1- First one is to fix @wordpress/create-block and stick to an old version of 2- Write a post on make/core that serves as a dev note quickly to explain the change and the potential impact on build tools. |
@youknowriad might I also suggest updating the CHANGELOG.md file? |
@justlevine The CHANGELOG already mentions the breaking change. Would you like to seem something else there? |
|
If the minimum required WP version is changing to 6.6 (as I understood your comment to mean), this should be noted directly. Even if it was included in the PR description, I'd recommend this - more so since it seems to be a side effect that isnt called out explicitly in #61692 |
It's not just I don't know whether updating the other packages but keeping |
I also had to downgrade |
The same issue is also being discussed on WordPress Slack (link requires registration at https://make.wordpress.org/chat/): https://wordpress.slack.com/archives/C02QB2JS7/p1717340775169699. |
In the same vein, what should package consumers do regarding From some quick testing, it doesn't seem to break anything by itself, at least in our case. |
I've opened #62265 to add a clearer note to the different impacted packages per the discussion above. Thanks for the suggestions. |
To address this issue, it would be nice to create a What is needed is the post install script that parses the package.json and something akin to the In this case if I had specified in my package.json
it should have thrown an error and said it is not compatible with my version of wp What do you think? I think it would be easy to implement and would be extremely beneficial. |
Restrict devDependencies versions. The latest @wordpress/scripts is not compatible with WP <6.6: WordPress/gutenberg#62202
This seems to have come back again as an issue when compiling blocks. It seems that I now again have to use "react" and not "react-jsx-runtime" when using the latest packages. I was using the following
And when I compile the loader fails because it expects react instead of react-jsx-runtime. |
Not sure if this is related (it seems like it), but the editor page within WP is no longer loading. The browser console is flooded with errors like |
@thelovekesh, I wasn't able to make the polyfill solution work. However, without any extra webpack config, just loading the file from the core directory worked for me in WP 5.5, like so: if ( ! wp_script_is( 'react-jsx-runtime', 'registered' ) ) {
wp_register_script(
'react-jsx-runtime',
'/wp-includes/js/dist/vendor/react-jsx-runtime.js',
array( 'react' ),
'18.2.0',
true
);
} I'm trying to understand what the extra webpack config does and why we need it, since registering these files didn't seem to work in my case. |
WP 5.5 doesn't have the The If possible, you should avoid harcoding |
Somehow this was working for me, but @jsnajdr, thanks for pointing this out, what you say makes sense. |
It seems that many people opt to stay on the old branch instead of adopting a polyfill solution, and I understand that. However, the old branch doesn't receive security updates introduced later, which becomes problematic. @TobiasBg, have you actually managed to make this work? I visited your repo and couldn't find the code. |
Seeing how @acicovic and others struggle with adding a We always encourage people to use the latest version of WordPress and everything related. It should be ok to use the latest version of It's also common that plugins support several versions of WordPress back. Supporting only the very latest version is very rare if not nonexistent. Therefore, the standard version (i.e., the latest) of Creating the I don't know how to solve this yet. Currently the JSX |
Maintaining backward compatibility can be challenging sometime for various reasons. In the current setup, everything should function correctly with the latest version of WordPress and the For those who need it, here is an example of a polyfill implementation: Polyfill Implementation. Additionally, include this PHP code to ensure the polyfill is loaded correctly: PHP Code for Polyfill. |
@thelovekesh, thanks for the links, I'll take a look. In the meantime, for anyone wanting to stay on the older version but get rid of the vulnerabilities, it's possible to add "overrides": {
"puppeteer-core": "^23.1.0"
}, You should test though that this change works well for your project. |
@acicovic: Yes, I have the polyfill code working fine, but unfortunately, it's not yet in a released branch of my plugin, which is why it's not yet in that repo. Sorry :-( But it's pretty much what has been discussed above. |
The code I had written in my attempt to update is already pretty close to the examples I'm seeing here. So I can only assume that there's something specific in my config that doesn't work as expected, and that I can't see it. This is my first time messing with webpack configs, so this doesn't help either. I think that @jsnajdr makes some great points. If many developers are postponing a pollyfil solution, what will happen when we're forced to go that route with React 19? I think there should be some official form of docs for that, and people who can help out on GitHub issues. |
More or less every WordPress plugin aims to support multiple versions, and I think it's not a reasonable ask that more or less everyone should understand the polyfills, be able to implement them themselves, or to be even aware that they are needed. What if the |
I totally agree, this would be very helpful. |
Description
I tried to create a new plugin / block with create-block and the block is not available in the back-end. There's no build error, php error or javascript error.
Step-by-step reproduction instructions
1 : Create a new wordpress plugin "npx @wordpress/create-block test-plugin"
2: cd test-plugin
3 : npm start
3 : activate plugin test-plugin
4 : edit a new page in wp-admin
5 : try to add the new block "/test-plugin"
6: nothing append
step to correct
Screenshots, screen recording, code snippet
No response
Environment info
Wordpress 6.53.
@wordpress/scripts": "^28.0.0"
node 22.2
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
The text was updated successfully, but these errors were encountered: