Include blocks manifest build process in Webpack config to fix create-block bug with missing blocks manifest file#69578
Conversation
… blocks manifest file.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @samikeijonen. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: 0 B Total Size: 1.84 MB ℹ️ View Unchanged
|
|
Flaky tests detected in cc80415. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/13860341130
|
|
I contributed one enhancement d01a653 that wasn't working in my testing - a custom output path provided for the build commands, example: wp-scripts start --blocks-manifest --output-path=dist |
| apply( compiler ) { | ||
| compiler.hooks.afterEmit.tap( 'BlocksManifest', () => { | ||
| exec( | ||
| `node ${ fromScriptsRoot( |
There was a problem hiding this comment.
I changed here two things in d01a653.
- Use the local script rather than
wp-scriptsexecutable so it can run locally in non-standard way. The way I usually test changes is by running../node_modules/.bin/wp-scripts start --blocks-manifest --output-path=distfrom the scaffolded block without the npm packages installed. This way I can use the latest version ofwp-scriptsfrom the Gutenberg repository. - I added a way to change the
--inputparam in the case when someone decides the build folder should live in a different location.
There was a problem hiding this comment.
Thanks for these fixes!
gziolo
left a comment
There was a problem hiding this comment.
Everything tested well for me. This is how I did it:
npx wp-create-block block-example --no-wp-scripts
cd block-example
../node_modules/.bin/wp-scripts build --blocks-manifest
../node_modules/.bin/wp-scripts start --blocks-manifest --output-path=distThere was a problem hiding this comment.
Can we update CHANGELOG.md and README.md and add a description of the new argument?
Probably around here:
gutenberg/packages/scripts/README.md
Lines 89 to 93 in 5f28621
gutenberg/packages/scripts/README.md
Lines 423 to 430 in 5f28621
|
@t-hamano I'm on vacation right now, so please feel free to amend this PR directly as needed. Looks like it's almost good to go, and +1 to documenting the new argument. |
|
Updated changelog and readme via 8cc1b0f |
|
I ask myself to know if the guys that are maintaining the @wordpress/create-block packages are aware of that? Could they simply update the packages for the scripts behave normally ???? |
|
@liothub Could you explain your question in a bit more detail? |
Is it normal that blocks-manifest.php be deleted with npm start ? No.... Then, it's denote a problem into the scripts.... a bug, a typo elsewhere.... The scripts are intended to work properly without having to hack them every two days... doesn't you agree?? |
|
Sorry, I'm not sure what you're asking. Do you mean that there is still a problem to be fixed in either |
The problem stays the same: npm start delete the blocks-manifest.php file which seats normaly into the build directory Its not a normal situation which have to be solved by the scripts developers Today's morning 10:00 AM in France, I install the script and there is still the problem... the version of the moment is I'm waiting for the new 'corrected' version :-) |
|
We should see the updated version of both packages |
Thanks !!! We can check here, I guess |
|
For now, for anyone reading and needing a simple solution until fix gets released: For Mac/Linux
For windows
Also in your-block-name.php replace under What this will do is to put the blocks-manifest.php in a dir folder and doesn't get deleted when using the |
It should be |
Packages have been updated since 2025 march-27 |
|
Here's a screen recording showing fatal error that appears upon activating the block plugin that's generated using the npx create-block command: https://u.pcloud.link/publink/show?code=XZHUhQ5ZTx8zedXvQsHBzOPbRAORzBB71Ol7 |
You should use --variant dynamic instead of --variant=dynamic forgot the = sign ..... |
I was following https://developer.wordpress.org/block-editor/getting-started/tutorial/ which says Nevertheless, just tried without the Still getting the same fatal error related to missing /build/blocks-manifest.php file when the new plugin is activated. |
The Wordpress doc here says --variant dynamic I tried myself in my PC with npx @wordpress/create-block@latest --variant dynamic zuzule and it works perfectly, I can activate the plugin, I can run npm run build and npm start without any problem. Maybe you have a local problem, try on a new fresh wordpress install in a new directory... |
This actually works better than what I suggested, good share @srikat |
|
If you are still having trouble resolving the issue, please check the following points one by one:
{
"scripts": {
"build": "wp-scripts build --blocks-manifest",
"start": "wp-scripts start --blocks-manifest"
}
}
|
Yes I was using the latest create-blocks according to the change logs and "@wordpress/scripts": "^30.14.0" |
I shared the workaround that others shared in a slightly easy-to-follow steps here: https://brickslabs.com/how-to-fix-fatal-error-after-creating-a-new-block-with-wordpress-create-block/ |
For me, negative to step 3.
|
|
Let's continue the discussion here to broadly investigate what the cause of the reported issue is: #69760 |
…e-block` bug with missing blocks manifest file (WordPress#69578) * Build blocks manifest as part of Webpack process if --blocks-manifest arg is present. * Use latest wp-scripts webpack argument in create-block to fix missing blocks manifest file. * Improve handling for block manifest to account to different build folders * scripts: update changelog and readme --------- Co-authored-by: Grzegorz Ziółkowski <grzegorz@gziolo.pl> Co-authored-by: Aki Hamano <tetsuaki.hamano@gmail.com>




What?
Closes #69565
How?
wp-scripts build-blocks-manifestas part of Webpack process if--blocks-manifestargument is present.create-block's generatedpackage.jsonto use that new--blocks-manifestargument instead of separately callingwp-scripts build-blocks-manifestwhich does not play well together with Webpack's own watch mode.Important: These changes affect
@wordpress/scriptsand@wordpress/create-block, and ideally both packages are released with these changes at the same time.That's because the
create-blockchange depends on thescriptschange.Testing Instructions
See #69565.