@@ -280,7 +280,10 @@ public function print_import_map() {
280280 */
281281 private function get_import_map (): array {
282282 global $ wp_scripts ;
283- $ classic_script_module_dependencies = array ();
283+
284+ $ imports = array ();
285+
286+ $ classic_script_dependencies = array ();
284287 if ( $ wp_scripts instanceof WP_Scripts ) {
285288 foreach ( $ wp_scripts ->registered as $ dependency ) {
286289 $ handle = $ dependency ->handle ;
@@ -297,19 +300,18 @@ private function get_import_map(): array {
297300 if ( ! $ module_deps ) {
298301 continue ;
299302 }
300- array_push ( $ classic_script_module_dependencies , ...$ module_deps );
303+ foreach ( $ module_deps as $ id ) {
304+ $ src = $ this ->get_src ( $ id );
305+ if ( null === $ src ) {
306+ continue ;
307+ }
308+ $ imports [ $ id ] = $ src ;
309+ $ classic_script_dependencies [] = $ id ;
310+ }
301311 }
302312 }
303313
304- $ imports = array ();
305- foreach ( $ this ->get_dependencies ( array_merge ( $ classic_script_module_dependencies , array_keys ( $ this ->get_marked_for_enqueue () ) ) ) as $ id => $ script_module ) {
306- $ src = $ this ->get_src ( $ id );
307- if ( null === $ src ) {
308- continue ;
309- }
310- $ imports [ $ id ] = $ src ;
311- }
312- foreach ( $ classic_script_module_dependencies as $ id ) {
314+ foreach ( $ this ->get_dependencies ( array_merge ( $ classic_script_dependencies , array_keys ( $ this ->get_marked_for_enqueue () ) ) ) as $ id => $ script_module ) {
313315 $ src = $ this ->get_src ( $ id );
314316 if ( null === $ src ) {
315317 continue ;
@@ -356,9 +358,6 @@ private function get_dependencies( array $ids, array $import_types = array( 'sta
356358 return array_reduce (
357359 $ ids ,
358360 function ( $ dependency_script_modules , $ id ) use ( $ import_types ) {
359- if ( ! isset ( $ this ->registered [ $ id ]['dependencies ' ] ) ) {
360- return $ dependency_script_modules ;
361- }
362361 $ dependencies = array ();
363362 foreach ( $ this ->registered [ $ id ]['dependencies ' ] as $ dependency ) {
364363 if (
0 commit comments