Create Block: Generate a block.json file#23399
Create Block: Generate a block.json file#23399gziolo merged 5 commits intoWordPress:masterfrom coreymckrill:add/create-block-json
Conversation
Writes a block.json file pre-populated with the input parameters from the script. The `editorScript`/`editorStyle` properties vary depending on which template is chosen (esnext or es5).
|
Nice one, I'll have a look later this week 👍 |
gziolo
left a comment
There was a problem hiding this comment.
I proposed that we explicitly set values for scripts and styles in the template config. What do you think? Everything else looks good. Thanks for taking care of it.
gziolo
left a comment
There was a problem hiding this comment.
The idea was to use the syntax similar to what npm uses for local packages:
file:./path/relative/to/block-json/file
I guess we could skip ./ if that helps. Let me know what you think. I will test it with register_block_type_from_metadata helper and merge it tomorrow.
In fact, we could do feature detection in ESNext template and use register_block_type_from_metadata when it's defined. I can open PR proposing that tomorrow.
Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl>
Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl>
I don't think it matters much either way, as long as the required syntax is well documented. |
* Create Block: Generate a block.json file Writes a block.json file pre-populated with the input parameters from the script. The `editorScript`/`editorStyle` properties vary depending on which template is chosen (esnext or es5). * Move script/style values to template config * Auto-fixed whitespace * Use npm syntax for file paths Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl> * Use npm syntax for file paths Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl> Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl>
|
Should we update the Right now things like name, title, description, etc.. are duplicated in the two locations. |
|
@mkaz, there are two issues that need to be resolved first:
In the past, I tried to build a Babel macro that would address both points but it wasn’t as straightforward as you would expect. We were afraid it could be a point of bugs when not configured properly. Related PR: #16088. |
|
I opened an issue that tracks i18n support for |
|
@gziolo Thanks for the update, I've added info to the Create a Block tutorial with a note for the block.json part. Can you review here: https://github.com/WordPress/gutenberg/pull/23654/files#diff-c52b6bb71644b3ce80dd15e4a3e42ac4 |
Description
#22151 suggests auto-generating the block.json file as a way to help block creators be set up for success in getting their blocks added to the block directory.
This adds block.json auto-generation to the
create-blockscript during the scaffolding process. The file is pre-populated with the inputs/defaults from the script. TheeditorScript/editorStyleproperties vary depending on which template is chosen (esnext or es5).How has this been tested?
Tested with a local checkout of Gutenberg, running
node path/to/create-block. Tested with bothesnextandes5values for thetemplateparameter.Types of changes
Checklist: