Create Block: Add missing viewScriptModule field#59140
Conversation
|
Size Change: 0 B Total Size: 1.7 MB ℹ️ View Unchanged
|
|
|
||
| ```bash | ||
| npx @wordpress/create-block --template @wordpress/create-block-interactive-template | ||
| npx @wordpress/create-block --template @wordpress/create-block-interactive-template |
|
Flaky tests detected in 43288b8. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7939878334
|
|
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 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. |
cbravobernal
left a comment
There was a problem hiding this comment.
Thank you SO MUCH for this PR. It was on my radar 🎉
|
@c4rl0sbr4v0 Thanks for the review! My understanding is that the |
We should publish it then asap. I guess we will publish npm packages on Monday or Tuesday before the Beta 2. |
|
I'm not familiar with how npm packages are released. Perhaps @gziolo knows more? |
| @@ -32,6 +32,7 @@ async function initBlockJSON( { | |||
| viewStyle, | |||
| render, | |||
| viewModule, | |||
There was a problem hiding this comment.
We don't need viewModule anymore in @wordpress/create-block. It's been replaced with viewScriptModule in all places now.
There was a problem hiding this comment.
Thanks for the feedback! I would like to submit a follow-up PR.
|
@t-hamano is correct. There is nothing to backport to WordPress core here as there is no production code included. At this period of WP major release, npm publishing with bug fixes doesn't target npm with the |
|
Thanks for noticing and handling this @t-hamano 🙌 |
Follow up #58211
What?
I noticed that when specifying an interactivity template in the
create-blockpackage, theviewScriptModulewas not added toblock.json, so the block did not work as expected on the front end.Why?
In #58211, a field was added to the interactivity template side, but it appears that the field is not added to the create-block package that actually generates
block.json.Testing Instructions
path/to/gutenberg/packages/create-block/index.js test-block --template path/to/gutenberg/packages/create-block-interactive-templatesrc/block.jsonfile.Before
{ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "create-block/test-block", "version": "0.1.0", "title": "Test Block", "category": "widgets", "icon": "media-interactive", "description": "An interactive block with the Interactivity API", "example": {}, "supports": { "interactivity": true }, "textdomain": "test-block", "editorScript": "file:./index.js", "editorStyle": "file:./index.css", "style": "file:./style-index.css", "render": "file:./render.php" }After
{ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "create-block/test-block", "version": "0.1.0", "title": "Test Block", "category": "widgets", "icon": "media-interactive", "description": "An interactive block with the Interactivity API", "example": {}, "supports": { "interactivity": true }, "textdomain": "test-block", "editorScript": "file:./index.js", "editorStyle": "file:./index.css", "style": "file:./style-index.css", "render": "file:./render.php", "viewScriptModule": "file:./view.js" }Also run the following command and make sure that no unintended fields are added to block.json as before.
path/to/gutenberg/packages/create-block/index.js test-blockpath/to/gutenberg/packages/create-block/index.js test-block --template path/to/gutenberg/packages/create-block-tutorial-template