-
Notifications
You must be signed in to change notification settings - Fork 4.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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed here two things in d01a653.
- Use the local script rather than
wp-scripts
executable 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=dist
from the scaffolded block without the npm packages installed. This way I can use the latest version ofwp-scripts
from the Gutenberg repository. - I added a way to change the
--input
param in the case when someone decides the build folder should live in a different location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for these fixes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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=dist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
- `--webpack-bundle-analyzer` – enables visualization for the size of webpack output files with an interactive zoomable treemap. | |
- `--webpack-copy-php` – enables copying all PHP files from the source directory ( default is `src` ) and its subfolders to the output directory. | |
- `--webpack-no-externals` – disables scripts’ assets generation, and omits the list of default externals. | |
- `--source-path` – allows customization of the source directory. The default is the project root `.` when [entry points are listed](#listing-entry-points) in the command, or `src` otherwise. | |
- `--output-path` – allows customization of the output directory. The default is the `build` folder. |
gutenberg/packages/scripts/README.md
Lines 423 to 430 in 5f28621
- `--hot` – enables "Fast Refresh". The page will automatically reload if you make changes to the code. _For now, it requires that WordPress has the [`SCRIPT_DEBUG`](https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/#script_debug) flag enabled and the [Gutenberg](https://wordpress.org/plugins/gutenberg/) plugin installed._ | |
- `--no-watch` – Starts the build for development without starting the watcher. | |
- `--webpack-bundle-analyzer` – enables visualization for the size of webpack output files with an interactive zoomable treemap. | |
- `--webpack-copy-php` – enables copying all PHP files from the source directory ( default is `src` ) and its subfolders to the output directory. | |
- `--webpack-devtool` – controls how source maps are generated. See options at https://webpack.js.org/configuration/devtool/#devtool. | |
- `--webpack-no-externals` – disables scripts’ assets generation, and omits the list of default externals. | |
- `--source-path` – allows customization of the source directory. The default is the project root `.` when [entry points are listed](#listing-entry-points) in the command, or `src` otherwise. | |
- `--output-path` – allows customization of the output directory. The default is the `build` folder. |
@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 |
What?
Closes #69565
How?
wp-scripts build-blocks-manifest
as part of Webpack process if--blocks-manifest
argument is present.create-block
's generatedpackage.json
to use that new--blocks-manifest
argument instead of separately callingwp-scripts build-blocks-manifest
which does not play well together with Webpack's own watch mode.Important: These changes affect
@wordpress/scripts
and@wordpress/create-block
, and ideally both packages are released with these changes at the same time.That's because the
create-block
change depends on thescripts
change.Testing Instructions
See #69565.