1
1
Fork
You've already forked wordpress
0

feature/native-blocks #1

Merged
JoshuaCrewe merged 22 commits from feature/native-blocks into main 2026年03月02日 11:44:30 +01:00

This is sort of working at least in terms of a POC. There are a bunch of improvements I would make if the ecosystem would allow me to.

  • Vite will not always auto compile code, sometimes it does it twice and then stops
  • Block creation is currently more verbose than I want it to be (I'd rather not have index.js for each block)
  • It is unreliable. Sometimes blocks will deregister (might be related to 1.)
This is sort of working at least in terms of a POC. There are a bunch of improvements I would make if the ecosystem would allow me to. - Vite will not always auto compile code, sometimes it does it twice and then stops - Block creation is currently more verbose than I want it to be (I'd rather not have index.js for each block) - It is unreliable. Sometimes blocks will deregister (might be related to 1.)
JoshuaCrewe left a comment
Copy link

Documentation is required for creating

  • A new block rendered in PHP
  • A new block rendered client side
  • Overriding the output of a core block
Documentation is required for creating - A new block rendered in PHP - A new block rendered client side - Overriding the output of a core block
@ -24,3 +61,4 @@
},
},
},
},
Author
Owner
Copy link

This configuration needs cleaning up. There are comments and commented out code as well as a partial breaking up of the file.

This configuration needs cleaning up. There are comments and commented out code as well as a partial breaking up of the file.
JoshuaCrewe marked this conversation as resolved
package.json Outdated
@ -16,1 +17,4 @@
"vite": "^7.2.2"
},
"devDependencies": {
"vite-plugin-static-copy": "^3.1.4"
Author
Owner
Copy link

I don't think we are using this anymore

I don't think we are using this anymore
JoshuaCrewe marked this conversation as resolved
@ -42,3 +42,3 @@
'mode' => false
],
'render_callback' => [&$this, 'render']
// 'render_callback' => [&$this, 'render']
Author
Owner
Copy link

Remove this code

Remove this code
JoshuaCrewe marked this conversation as resolved
@ -46,0 +47,4 @@
$options['render_callback'] = [&$this, 'render'];
}
// If there is no save.jsx then we can make the render callback
Author
Owner
Copy link

Expand this comment and place with the code directly above it

Expand this comment and place with the code directly above it
JoshuaCrewe marked this conversation as resolved
@ -49,3 +54,3 @@
public function render($attributes)
{
$this->context['post'] = new Timber\Post();
// $this->context['post'] = new Timber\Post();
Author
Owner
Copy link

This was commented out to make work. It should either be removed or replaced

This was commented out to make work. It should either be removed or replaced
JoshuaCrewe marked this conversation as resolved
@ -0,0 +2,4 @@
use websiteblocks\Block;
add_action('admin_enqueue_scripts', function () {
Author
Owner
Copy link

This could be perhaps made less verbose, it was taking from the front end enqueue which has more of a scope than it does here.

This could be perhaps made less verbose, it was taking from the front end enqueue which has more of a scope than it does here.
Author
Owner
Copy link

We do need to think about enqueuing a stylesheet on the admin side as well to handle any weird overrides which are needed or tweak some styles.

We do need to think about enqueuing a stylesheet on the admin side as well to handle any weird overrides which are needed or tweak some styles.
Author
Owner
Copy link

I think I want to handle editor styles via its own issue/PR

I think I want to handle editor styles via its own issue/PR
Author
Owner
Copy link

#2

https://codeberg.org/JoshuaCrewe/wordpress/issues/2
JoshuaCrewe marked this conversation as resolved
@ -0,0 +51,4 @@
if (file_exists(dirname($path) . '/save.php')) {
include_once dirname($path) . '/save.php';
continue;
}
Author
Owner
Copy link

This is some legacy code which could do with being connected up. This is to allow for overriding the output of the native blocks where that is appropriate.

This is some legacy code which could do with being connected up. This is to allow for overriding the output of the native blocks where that is appropriate.
Author
Owner
Copy link

Probably should be render.php maybe ?

Probably should be render.php maybe ?
Author
Owner
Copy link

save.php makes sense here. The idea is that this file replaces save.jsx and calls Block('paragraph', true) along with a render.twig to overwrite what gets output for a core block

`save.php` makes sense here. The idea is that this file replaces `save.jsx` and calls `Block('paragraph', true)` along with a `render.twig` to overwrite what gets output for a core block
JoshuaCrewe marked this conversation as resolved
Author
Owner
Copy link

I would like to upgrade the vite config to not fully rely on the rollup build but actually use the HMR. This would be more inline with what vite is expecting perhaps and might resolve the issue where the build isn't triggered reliably. Then we can do a single build for production.

We also need to update it to use the rolldown config as this will be coming in and I want to make sure the file names and rollup config get carried over or if I need to rewrite them

I would like to upgrade the vite config to not fully rely on the rollup build but actually use the HMR. This would be more inline with what vite is expecting perhaps and might resolve the issue where the build isn't triggered reliably. Then we can do a single build for production. We also need to update it to use the rolldown config as this will be coming in and I want to make sure the file names and rollup config get carried over or if I need to rewrite them
Author
Owner
Copy link

As far as I know, the build system is working. There is an issue on one of my machines where the JS/TS files compile once under --watch. This appears to be an issue with the machine rather than the configuration. The same config works as expected for the hacking machine but not for the XPS. They are both on the same OS which are setup very similarly. It would be interesting to see what happens on a third machine. There is one other machine I have which is on the same OS and one which is MacOS.

To merge this :

  • Confirm the two test blocks appear in the editor
  • (削除) Enqueue styles to editor (削除ここまで)
  • Be able to edit core block output
  • Resolve formatting comments above
  • Update paths to assets in enqueue function

As a bonus, if the HMR could be configured even if it can't be used it might be a solution to the problem machine. The reason I don't want it is because I don't want to have to keep the development server port open when working on multiple projects at the same time. To get it working we are looking at :

  • Updating package.json to use vite watch
  • Figuring out what the path on the dev server the assets are served at (this seems basically impossible)
  • Create a PHP function to detect this mode and load via the above figured out URL
  • Mode detection is best by looking for the hot file (make sure this is output to somewhere)
node : 25.6.1
https://github.com/paulmillr/chokidar?tab=readme-ov-file#getting-started
As far as I know, the build system is working. There is an issue on one of my machines where the JS/TS files compile once under --watch. This appears to be an issue with the machine rather than the configuration. The same config works as expected for the hacking machine but not for the XPS. They are both on the same OS which are setup very similarly. It would be interesting to see what happens on a third machine. There is one other machine I have which is on the same OS and one which is MacOS. To merge this : - [X] Confirm the two test blocks appear in the editor - [ ] ~~Enqueue styles to editor~~ - [X] Be able to edit core block output - [X] Resolve formatting comments above - [X] Update paths to assets in enqueue function As a bonus, if the HMR could be configured even if it can't be used it might be a solution to the problem machine. The reason I don't want it is because I don't want to have to keep the development server port open when working on multiple projects at the same time. To get it working we are looking at : - Updating package.json to use `vite watch` - Figuring out what the path on the dev server the assets are served at (this seems basically impossible) - Create a PHP function to detect this mode and load via the above figured out URL - Mode detection is best by looking for the hot file (make sure this is output to somewhere) ``` node : 25.6.1 https://github.com/paulmillr/chokidar?tab=readme-ov-file#getting-started ```
Author
Owner
Copy link

@JoshuaCrewe wrote in #1 (comment):

As a bonus, if the HMR could be configured even if it can't be used it might be a solution to the problem machine. The reason I don't want it is because I don't want to have to keep the development server port open when working on multiple projects at the same time. To get it working we are looking at :

* Updating package.json to use `vite watch`
* Figuring out what the path on the dev server the assets are served at (this seems basically impossible)
* Create a PHP function to detect this mode and load via the above figured out URL
* Mode detection is best by looking for the hot file (make sure this is output to somewhere)

Issue created to address this in #3

@JoshuaCrewe wrote in https://codeberg.org/JoshuaCrewe/wordpress/pulls/1#issuecomment-11095271: > As a bonus, if the HMR could be configured even if it can't be used it might be a solution to the problem machine. The reason I don't want it is because I don't want to have to keep the development server port open when working on multiple projects at the same time. To get it working we are looking at : > > * Updating package.json to use `vite watch` > > * Figuring out what the path on the dev server the assets are served at (this seems basically impossible) > > * Create a PHP function to detect this mode and load via the above figured out URL > > * Mode detection is best by looking for the hot file (make sure this is output to somewhere) Issue created to address this in https://codeberg.org/JoshuaCrewe/wordpress/issues/3
Sign in to join this conversation.
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
JoshuaCrewe/wordpress!1
Reference in a new issue
JoshuaCrewe/wordpress
No description provided.
Delete branch "feature/native-blocks"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?