-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Labels
Developer ExperienceIdeas about improving block and theme developer experienceIdeas about improving block and theme developer experience[Feature] Block APIAPI that allows to express the block paradigm.API that allows to express the block paradigm.[Type] Developer DocumentationDocumentation for developersDocumentation for developers
Description
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.
<?php
$script_asset_path = wp_normalize_path(
realpath(
dirname( $metadata['file'] ) . '/' .
substr_replace( $script_path, '.asset.php', - strlen( '.js' ) )
)
);
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
- Follow the instructions at https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/writing-your-first-block-type/ to create a Hello World block, using the Plain JS options with no build process.
- Observe that the block is not registered. Instead the error "Notice: register_block_script_handle was called incorrectly. The asset file for the "editorScript" defined in "gutenberg-examples/example-01-basic" block definition is missing." is displayed.
- Add an empty block.asset.php file to the plugin directory.
- Observe that the error goes away and the block can then be added in the editor.
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
AnupamKhosla, strarsis, Inclushe, mdjwel, stormrockwell and 5 more
Metadata
Metadata
Assignees
Labels
Developer ExperienceIdeas about improving block and theme developer experienceIdeas about improving block and theme developer experience[Feature] Block APIAPI that allows to express the block paradigm.API that allows to express the block paradigm.[Type] Developer DocumentationDocumentation for developersDocumentation for developers