block.json: render
files not copied to build/
folder for Core blocks
#63077
Labels
Gutenberg Plugin
Issues or PRs related to Gutenberg Plugin management related efforts
[Type] Bug
An existing feature does not function as intended
Description
While working on #62092, I discovered that if a Core block's
block.json
file contains arender
field that specifies a PHP file to render the block, that file is not copied to thebuild/
folder. This means that if a Core block were to use therender
field, it would break.The same is not a problem for third-party blocks, as they are handled by code in
wp-scripts
(added by #43917 and amended by #51162).By contrast, Core blocks are built using a special Webpack config in; while there is code to copy their
index.php
files to thebuild/
folder, there's none to handlerender
files.This is currently reflected by the fact that no Core blocks are using the
render
field. However, it is somewhat confusing that they cannot use a documented API that is available for third-party blocks.Step-by-step reproduction instructions
The following patch moves the Template Part block's render callback from its
index.php
to a newly createdrender.php
, and adds arender
field toblock.json
that points to that file.Apply the patch and rebuild Gutenberg. Note that Template Part blocks no longer work on the frontend (they appear blank), and that the
render.php
file is missing frombuild/block-library/blocks/template-part/
.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: