-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Create Block: Generate a block.json file #23399
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 👍 |
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 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.
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.
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 <[email protected]>
Co-authored-by: Greg Ziółkowski <[email protected]>
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 <[email protected]> * Use npm syntax for file paths Co-authored-by: Greg Ziółkowski <[email protected]> Co-authored-by: Greg Ziółkowski <[email protected]>
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-block
script during the scaffolding process. The file is pre-populated with the inputs/defaults from the script. TheeditorScript
/editorStyle
properties 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 bothesnext
andes5
values for thetemplate
parameter.Types of changes
Checklist: