Home › Forums › Gutenberg › Load JS in editor with block.json › Reply To: Load JS in editor with block.json
Has anyone ran into an issue when using wp-scripts
package that the {block}.asset.php file gets auto-generated but has blank dependencies? For example, I have an editor.asset.php
file in my src
block files with the following code:
<?php
return array(
'dependencies' => array(
'wp-element',
'wp-blocks',
'acf-input', // way to make block js wait for window.acf to exists
)
);
However, when wp-scripts
generates my build
directory, that file is generated/copied, however the contents is now:
<?php return array('dependencies' => array(), 'version' => '9f262c201bd7fd5a3679');
I was digging into the actual code within the node package that generates the contents of this file, and it appears the if
statement within this code block never runs because this.externalizedDeps
is always just an empty set.
const chunkDeps = new Set();
if ( injectPolyfill ) {
chunkDeps.add( 'wp-polyfill' );
}
const processModule = ( { userRequest } ) => {
if ( this.externalizedDeps.has( userRequest ) ) {
chunkDeps.add( this.mapRequestToDependency( userRequest ) );
}
};
Any thoughts..?
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.