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:
- wp_add_inline_script without dependency
- What are the benefits of using wp_enqueue_script?
- What are all the query parameters for getEntityRecords?
- How to use wp.hooks.addAction() in React JS/Gutenberg?
- How to use Head JS with all enqueued scripts?
- How to only enqueue block javascript on the frontend when its needed [duplicate]
- Remove extra Google Maps script
- Extend core block in Gutenberg
- Is it possible to enqueue the Youtube API script or does it have to be inline?
- Gutenberg custom block plugin with custom image sizes
- Include jQuery UI as a whole
- How to echo JS right after enqueued script to put it into noConflict mode?
- Correct place to register and enqueue scripts
- Get loading state of wp data selector
- Hooking a callback into the code within a Gutenberg block
- Load multiple Javascript scripts
- WP script versioning breaks cross-site caching?
- initial open/toggle PluginDocumentSettingPanel panel in document setting block editor gutenberg
- Correctly handling WordPress core data retrieval in Gutenberg
- Is there a client side API for handling transients or options?
- Javascript not included
- Move all the JS files to the bottom|footer, the right way
- How to add JavaScript file using wp_enqueue_scripts?
- Adding a text element in between title and blocks container
- Gutenberg RichText
- Use useSelect/useDispatch instead of withSelect/withDispatch
- How to handle Gutenberg wp.data async errors?
- How to use wp.hooks.addAction() in React JS/Gutenberg?
- How do I access site and block editor state data and use `useSelect()` or `withSelect()` to bind it to my components?
- Block Editor: How to get title and post content within the WordPress admin UI in Javascript?
- Custom block SelectControl works but equivalent ComboboxControl gives errors – where’s my mistake?
- wp_enqueue_scripts is not working in my plugin
- Gutenberg add extra attributes to custom format
- event/callback on block update?
- Exclude JS file from 404 error page
- How to remove p / br elements from gutenbergs editor
- Building a slide down search box in wordpress
- How to disable inline css styles generated by Gutenberg editor?
- Gutenberg getMedia() in post query doesn’t return all featured images
- How to transform a legacy widget into a block
- Gutenberg select categories
- Listening change event of taxonomy term checkboxes in Gutenberg editor
- What is the correct way to import the blocks-editor?
- Open MediaUpload from external component in Gutenberg
- Gutenberg extend blocks add new class name
- Search for a keyword across post types in a Gutenberg component
- wp_enqueue_script not loading my custom js file
- Using apiFetch for retrieving post data in Gutenberg
- Scripts not loading through function Method in WordPress Theme
- Looping over wordpress meta to create “ ‘s?
- How to load an additional script for a block in the block editor?
- Gutenberg consume wp-json data and reflect in frontend the content
- Why is JavaScript being added to header as application/oembed?
- wp_enqueue_scripts not enqueing correctly
- Video script issue, JavaScript attribute remains ‘undefined’
- Trigger wp-embed via JavaScript to refresh iframe preview?
- Gutenberg getBlockIndex in save() function
- Widgets and Post/Page edit/new blank, console errors only, no server errors
- Conditional save return on Gutenberg Block
- Can I alter the block editor’s paste text behavior?
- Custom Gutenberg block: access dom element via JavaScript
- Custom Block – save.js function not saving attributes
- Add crossorigin to SCRIPT tag
- Add script to page at certain location in wordpress
- How do I know if I should enqueue JS code or just include it in ONE PHP function?
- JavaScript Libraries in WordPress
- Setting Variable Path to Template Directory inside Script
- Bootstrap bundle present in page source but not working
- Dynamically add Js
- JS / jQuery in Elementor pages vs JS file
- Including dependencies using @wordpress/dependency-extraction-webpack-plugin
- Uncaught TypeError: r is not a function
- How to pass data to javascript in custom widget class
- WP Gutenberg – custom block with two content fields
- How do I make a savable preview like Youtube Gutenberg block?
- Proper way of minifiying java script files in wordpress theme
- 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?
- How to delay display of page elements until enqueued script has injected html
- Enqueue concatinated JS file in WordPress
- Javascript file doesn’t load
- early enqueueing javascript file in page template, not in functions.php
- Dequeue set-post-thumbnail.min.js
- jQuery + more won’t load in header
- 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
- Table block variation with header section activated
- Filtering Gutenberg Components, not Blocks
- How to load JavaScript modules with script_loader_tag hook?
- 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?
- How to add more elements to an already existing section in Gutenberg