-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
What problem does this address?
Part of #41236.
When registering a script via block.json, there is no way to specify a dependency. I understand that webpack uses a script to create index.asset.php
with wordpress dependencies, but that doesn't work for other scripts. Our organization has some wordpress scripts which are core to our experience and relied on by other blocks/plugins. When I use block.json to register my block like "editorScript": [ "file:./index.js" ],
, there's no way to declare those core scripts as dependencies. And doing it this way: "editorScript": [ "my-core-script", "file:./index.js" ],
doesn't work either.
See this discussion also: #46589
What is your proposed solution?
Allow the existing WPDefinedAsset
shape of input to be used along with the filepath method of registered a script. It might look like this:
"editorScript": [
{
"src": "file:./index.js",
"dependencies": [ "my-core-script" ],
"version": false,
}
],
// could also still use current method
"viewScript": [ "file:./index.j" ]