-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Blocks without asset.php file cannot be registered #40447
Comments
Thanks for creating this issue @kmonahan. I had been working on this for a few hours before realizing that the missing We'd love to avoid building that file using |
We have a decent proposal to extend |
Thanks a lot for bring this up, I was learning through the tutorial and couldn't figure out why the custom block is registered but doesn't show in the Gutenberg editor. I tried to debug:
The output gives a proper registered block which has But I couldn't understand this and then I installed the whole Heck man, WordPress documentation should explicitly mention this. |
Yes, I see now where the confusion comes from. I’ll see how we could improve that. |
+1, had to walk through the code to find that there is a condition for the existence of such a
Notably:
Edit: I just updated to the latest |
I encountered this issue going through the Create a basic block tutorial from the Block Editor Handbook. Not fun. |
@Inclushe: I updated to latest version of The documentation should mention this was added with more recent versions of |
@kmonahan thanks for opening this issue and sorry for the frustrating experience! I think we can start by updating the tutorial to be more clear about the need for the |
@ryanwelcher: And I am right with the assumption/experience that updating |
@strarsis The |
There was a missing step in the plain javascript documentation which missed out adding the asset file. Issue WordPress#40447
There was a missing step in the plain javascript documentation which missed out adding the asset file. Issue #40447
@ryanwelcher can we close this based on #41511 being merged? |
Having gone through the same discovery process as others here, I would suggest tweaking the error message.
"editorScript": "file:./block.js", As a relative novice, I interpreted the message as meaning WP couldn't find my Maybe the improvement could be as tiny as the following? At least in my case, it would have put me on the right track a lot sooner.
|
I found that when using plain webpack or just a custom webpack config for wp-scripts build then you also lose the index.asset.php file (as well as no longer recognising all of the core wp dependencies as externals, resulting in a huge bundle file). In the end I found the solution by inspecting the default webpack config in It would be helpful if this was more clearly documented upfront that this is a pretty much hard requirement for any project building with plain webpack or a seperate custom webpack config. |
I'm closing this issue as it has been addressed by PR #41511. Feel free to request that it be re-opened if you feel that there is still an issue here. |
Description
Blocks without an .asset.php file, such as the Hello, World block from the Building a Basic Block tutorial, result in a PHP notice during the registration process.
results in $script_asset_path being set to an empty string when no .asset.php file exists, triggering the _doing_it_wrong error.
If this is the intended behavior, the tutorial steps should probably be updated to include a step to manually create that file when the build tools aren't being used.
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
No response
Environment info
No response
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: