Yes you can use the index.asset.php file in the ‘enqueue_block_editor_assets’ action. I guess you missed to npm install the dependencies you want to use and import them in your script. That’s how @wordpress/scripts generates your asset.php file. If you do not import the dependencies in your JavaScript files the dependency management of asset.php wont work.
For example:
npm install @wordpress/api-fetch --save
In your script:
import apiFetch from '@wordpress/api-fetch;
Related Posts:
- What does wp-embed.min.js do in WordPress 4.4?
- wp_add_inline_script without dependency
- How to use wordpress default Password Strength Meter script
- Trigger Javascript on Gutenberg (Block Editor) Save
- Gutenberg – remove / add blocks with custom script
- What are the benefits of using wp_enqueue_script?
- What are all the query parameters for getEntityRecords?
- Register and enqueue conditional (browser-specific) javascript files?
- How to use wp.hooks.addAction() in React JS/Gutenberg?
- wp_enqueue_script() not working at all
- How to dequeue a script?
- Any advantage of using wp_scripts and is_IE when enqueuing scripts
- How to use wp_localize_script in custom page template?
- How to use Head JS with all enqueued scripts?
- Issue migrating a checkbox-type meta field to the block editor
- How to pass data to javascript in custom widget class
- Update block once an API request returns with a value
- Gutenberg – dynamically created element: how to set onChange?
- Custom block update rendering when reused
- WordPress Gutenberg Ajax request
- Loading two versions of same JS libary
- WP Gutenberg – custom block with two content fields
- How do I make a savable preview like Youtube Gutenberg block?
- Gutenberg Edit Block Inspector Controls and save
- Proper way of minifiying java script files in wordpress theme
- Spans in gutenberg
- iFrame onLoad in custom Gutenberg block
- Escaping quotes while enqueuing scripts
- How to register or enqueue script and stop it being called in head?
- How to correctly load this jquery script through the file functions.php?
- Adding javascript script to header via functions.php
- How to delay display of page elements until enqueued script has injected html
- load-scripts.php loads incorrect file names
- Enqueue concatinated JS file in WordPress
- wp_enqueue_scripts doesn’t work for template pages
- JavaScript and Google PageSpeed + wp_enqueue_script
- Javascript file doesn’t load
- Put dynamic Javascript in header after doing operations
- early enqueueing javascript file in page template, not in functions.php
- Dequeue set-post-thumbnail.min.js
- jQuery + more won’t load in header
- WOW.js Script Tag Initialization Header/Footer
- JS enqueue path (localhost)
- Why can’t I load JS script in a plugin?
- Script loaders vs wp_enqueue_script
- convertEntities() used before it is defined
- Block pattern conflict with custom block
- JavaScript file successfully registered but does not render correctly
- wp_enqueue has a resource but doesn’t generate a script tag [duplicate]
- Orbit Slider and Events Manager Plug-in JavaScript
- WordPress Gutenberg: Attribute overwritten by block duplicate
- Table block variation with header section activated
- Filtering Gutenberg Components, not Blocks
- Where to include JS library in gutenberg blocks
- How to load JavaScript modules with script_loader_tag hook?
- How to delete child block for associated parent block
- Passing object to FormTokenField suggestions
- Uncaught ReferenceError: tippy is not defined
- How to detect if we are in the Site Editor part of the Block Editor (as opposed to editing a Page/Post) in JavaScript?
- How can I show a Slot/Fill in the block editor
- How to securely set dynamic HTML content with JavaScript?
- Is it possible to add javascript to template parts
- How to add a new attribute to core wp block editor without npm?
- How to add more elements to an already existing section in Gutenberg
- How do i get an Inline style in Gutenberg Block show up in front end?
- WordPress adds and tags into HTML blocks after saving
- Gutenberg core/file add style support in js/ json
- Working with a non-React external library in a custom block
- Create Youtube embed block with createBlock
- How can I access custom data fetched from posts in a javascript script?
- How to add a css class to postTitleWrapper in Gutenberg?
- Masonry gallery block is working in the block editor but not the template editor
- How to change the selected Template using javascript?
- How to import the imagesLoaded and Masonry libs that come with WP in a Gutenberg block?
- Why is my JS not working on initial load?
- Additional CSS classes not being added in Gutenberg editor
- How do I filter/modify the updated content on save using javascript?
- config @wordpress/scripts with webpack and postCSS features
- Jest Unit tests for High order component containing Block Editor
- Embedded data and the _fields parameter in getEntityRecords
- Include Block Variation Within InnerBlocks
- Force-update the meta variable first set using `var [ meta, setMeta = useEntityProp( ‘postType’, postType, ‘meta’ );`
- How to execute some javascript code in the editor when a block pattern is added?
- How to build BOTH non-block components and blocks present in the /src directory using @wordpress/scripts
- How to add an additional dependency to a block index.asset.php file
- Why is the Gutenberg editor not recognizing my updates?
- WordPress Gutenberg Custom Block the viewScript does not get loaded on the frontend when my block is inserted
- How to transform a shortcode into a block
- Metabox conditionals depending on post format and template in Gutenberg
- How to re-render Gutenberg component when object instance is available
- useSelect() plus resolver result is serving cached data incorrectly
- How to access current discussion settings in gutenberg via JS?
- Custom gutenberg block refuses to load viewScript and I don’t know why
- Gutenberg DatePicker component with time set to zero
- Why Is wp.editor Not Adding the ”Add Media” Button When I Initialize It?
- How to render HTML content using the Interactivity API?
- Extend WordPress Gutenberg core/navigation-link
- How to auto rename JS files to prevent browser cache issues
- How to get selected category objects in the block editor?
- How to render initial posts on page load in a Gutenberg block using the Interactivity API?