-
Notifications
You must be signed in to change notification settings - Fork 4k
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. |
@youknowriad What currently is defined/documented (and where) regarding JS packages versioning, breaking changes, and forward/back-compatibility? |
There's some details here https://developer.wordpress.org/block-editor/contributors/code/backward-compatibility/ |
JSX in WordPress 6.6 got published with the clarification about the challenges with dev tooling around the upcoming major WP release. I also closed #62327 as a duplicate as it contains similar reports as above. |
Do we need to do the package release to fix issue with |
@Mamaduka yes, I thought this would happen as part of the beta/RC backports. |
I am having the same error; my temporary walkaround to update wordpress to 6.6 Beta. Here is how: Follow this to install the plugin. on wp-admin page, if I install WordPress Beta Tester, then update WordPress version, I can see the plugin. |
We can't update to latest @wordpress/dependency-extraction-webpack-plugin and latest @wordpress/scripts (at the time of committing 28.0.0) because a BC issue is causing it doesn't work for WP lower than 6.6. See WordPress/gutenberg#62202 (comment) [MAILPOET-6054]
Instead of downgrading the packages, add a polyfill for WP versions below 6.6. This will be necessary anyway when upgrading to React 19 and ensuring compatibility with older WP versions. Add the config to bundle the JSX runtime (webpack example here): const reactJSXRuntimePolyfill = {
entry: {
'react-jsx-runtime': {
import: 'react/jsx-runtime',
},
},
output: {
path: path.resolve(__dirname, 'assets/js'),
filename: 'react-jsx-runtime.js',
library: {
name: 'ReactJSXRuntime',
type: 'window',
},
},
externals: {
react: 'React',
},
// Other config...
};
module.exports = [ reactJSXRuntimePolyfill ]; and later register the script for WP < 6.6 with wp_register_script(
'react-jsx-runtime',
'path/to/react-jsx-runtime.js',
[ 'react' ],
'18.3.0',
true
); |
We can't update to latest @wordpress/dependency-extraction-webpack-plugin and latest @wordpress/scripts (at the time of committing 28.0.0) because a BC issue is causing it doesn't work for WP lower than 6.6. See WordPress/gutenberg#62202 (comment) [MAILPOET-6054]
We can't update to latest @wordpress/dependency-extraction-webpack-plugin and latest @wordpress/scripts (at the time of committing 28.0.0) because a BC issue is causing it doesn't work for WP lower than 6.6. See WordPress/gutenberg#62202 (comment) [MAILPOET-6054]
Great suggestion @thelovekesh that's indeed a valid solution as well. Would you mind sharing it as a comment on the dev note here https://make.wordpress.org/core/2024/06/06/jsx-in-wordpress-6-6/ I'm going to close this issue for now. Thanks all. |
Thanks @youknowriad. I have added a comment on the devnote - https://make.wordpress.org/core/2024/06/06/jsx-in-wordpress-6-6/#comment-46779. |
To add on to @thelovekesh's code suggestion: if ( ! wp_script_is( 'react-jsx-runtime', 'registered' ) ) {
wp_register_script(
'react-jsx-runtime',
'path/to/react-jsx-runtime.js,
[ 'react' ],
'18.3.1',
true
);
} I'm now running this in my plugin's action hook handler for the |
@thelovekesh I am sorry, which path is meant here? since path and dirname where undefined I put in some hardcoded paths by try&error e.g. to the plugin, to my custom theme etc) but I always end up with "module is not defined" and I am really stuck. can you please explain what to do exactly? |
@l-schwitzkowski: You should be able to replace that line by path: `${ __dirname }/assets/js`, and just the path for the file. |
@TobiasBg Thank you, I really do appreciate any help at this point. |
@l-schwitzkowski: Sorry, I don't have experience with using a manual build step like that. I use wp-scripts with a webpack.config.js, where I could then make the code changes from above. |
We can't update to latest @wordpress/dependency-extraction-webpack-plugin and latest @wordpress/scripts (at the time of committing 28.0.0) because a BC issue is causing it doesn't work for WP lower than 6.6. See WordPress/gutenberg#62202 (comment) [MAILPOET-6054]
@TobiasBg Thanks anyway :) Using wordpress 6.6 beta (1) solved the issue for now |
@l-schwitzkowski: Yes, that will work, but remember that files created that way now will not be able to run with WP < 6.6, without the polyfill. |
@TobiasBg That is absolutely fine as its a new side-project. Still we are trying to figure out a solution to make our monolithic main project work within 6.6+ in the future. Until now i didnt have time to check the workarounds within this environment but hopefully there will be a solution until needed. |
Restrict devDependencies versions. The latest @wordpress/scripts is not compatible with WP <6.6: WordPress/gutenberg#62202
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: